Report this

What is the reason for this report?

Express req.secure returning false on https connection

Posted on May 15, 2021

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



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!

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.

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

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.