Question

Express req.secure returning false on https connection

Posted May 15, 2021 97 views
NginxNode.jsLet's EncryptDigitalOcean Droplets

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

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.

×
Submit an Answer
2 answers

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

by Kathleen Juell
by Erika Heidi
Let's Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. In this tutorial, you will use Certbot to obtain a free SSL certificate for Apache on Ubuntu 18.04 and set up your certificate to renew automatically.
Show answer This answer has been marked as resolved by shareefhadid.