Configure Nginx for HTTPS - cannot establish secure connection!

Posted September 20, 2016 8.1k views
NginxUbuntu 16.04

So I got the website up and running, got HTTPS working and configured Nginx to redirect http calls over to HTTPS

sudo nano /etc/nginx/sites-enabled/default

# HTTP - redirect all requests to HTTPS:
server {
        listen 80;
        listen [::]:80 default_server ipv6only=on;
        return 301 https://$host$request_uri;

All seems to be working great! So goes out and have a coffee at a fast food restaurant in the city. They have wifi available so decide to check out the new website.
Problem is it comes back with an error - “cannot establish an secure connection” - I am assuming their free wifi is configured not to allow HTTPS calls.

I hate to think the website may be unavailable (think of all the new users I am going to lose!). I could disable the nginx redirect to https - but my problem is the app uses needs access to the microphone and without HTTPS you get horrible request boxes.

So my question is there anyway to configure the HTTPS redirect so that if it fails to will go to normal http?


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
1 answer

I think you need to remove the “ipv6only=on” part.