Question

Express req.secure returning false on https connection

Hi,

I am working on an node/express server and have set up nginx with lets encrypt and cerbot on my Droplet. When I access my ip I get the green lock and it says the connection is secure. However, when I try to log req.secure in Express it returns false. As a result, I am having trouble using session authentication with secure cookies.

Some posts are suggesting it could be due to the proxy or load balancer. I am not super familiar with with Digital Ocean, is the a problem others have had? Did I set up my SSL incorrectly (and somehow still get the green lock)?

Thank you in advance


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Sorry, I forgot to update this. The issue was with my NGINX Config Headers (Forwarder headers in particular).

Hi there,

Could you confirm how exactly didi you issue an SSL certificate for your IP address? If you run an SSL check for your IP do you get any errors:

https://www.sslshopper.com/ssl-checker.html

Usually, I tend to stick to Let’s encrypt as per this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-18-04

If you don’t yet have a domain name for that specific project, you could register a free one with Freenom.

Regards, Bobby