Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Nginx Redirect Requests to https://www

  • 14-02-2017 04:05PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    I have my below nginx config, I'm trying to redirect everything to https://www regardless of what comes in for example http://example.com, http://www.example.com or https://example.com.

    I can't ever get https://example.com to redirect to the https://www pattern!?
    	server {
            listen          80;
            listen          443 ssl;
            server_name     example.com;
            return          301 https://www.example.com$request_uri;
        }
    
        server {
            listen       443 ssl;
    
            ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
            ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_prefer_server_ciphers on;
            ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
            ssl_dhparam /etc/nginx/ssl/dhparams.pem;
            ssl_session_timeout 30m;
            ssl_session_cache shared:SSL:10m;
            ssl_buffer_size 8k;
            add_header Strict-Transport-Security max-age=31536000;
    
            root         /usr/share/nginx/html;
    
            # Load configuration files for the default server block.
            include /etc/nginx/default.d/*.conf;
    
            location / {
            }
    
            error_page 404 /404.html;
                location = /40x.html {
            }
    
            error_page 500 502 503 504 /50x.html;
                location = /50x.html {
            }
        }
    


Advertisement