Basic Question: Unable to access https:// with www prefix

lukemroz nginx-forum at forum.nginx.org
Thu Aug 4 15:03:34 UTC 2016


Hello,

I followed the instructions at Digital Ocean for setting up a WordPress
installation, including enabling HTTPS on the nginx server.  

(The instructions are here: 
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04)

When accessing https://www.comfortglobalhealth.com, I am always redirected
to https://comfortglobalhealth.com.  Can someone suggest what change I need
to make to my nginx configuration file so that this redirect doesn't
happen?

Thanks,
Luke

Here is my config:

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name comfortglobalhealth.com www.comfortglobalhealth.com;
        return 301 https://$server_name$request_uri;
        }

server {
        listen 443 ssl http2 default_server;
        listen [::]:443 ssl http2 default_server;
        include snippets/ssl-comfortglobalhealth.com.conf;
        include snippets/ssl-params.conf;
        root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name comfortglobalhealth.com www.comfortglobalhealth.com;
    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; allow all;
}
    location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
}

        location / {
                try_files $uri $uri/ /index.php$is_args$args;
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;

                fastcgi_pass 127.0.0.1:9000;
        }
        location ~ /\.ht {
                deny all;
        }
        location ~ /.well-known {
                allow all;
        }
}

Here are my snippets:

ssl-comfortglobalhealth.com.conf:
ssl_certificate
/etc/letsencrypt/live/www.comfortglobalhealth.com/fullchain.pem;
ssl_certificate_key
/etc/letsencrypt/live/www.comfortglobalhealth.com/privkey.pem;

ssl-params.conf:
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
ssl_dhparam /etc/ssl/certs/dhparam.pem;

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,268775,268775#msg-268775



More information about the nginx mailing list