My site don't works without https


#1

My site works fine using the url https://mysite.com. But when I try mysite.com just open the nginx “welcome page”.

my site conf

server {
    listen 443;

    server_name mysite.com;

    ssl on;
    ssl_certificate /var/www/mysite.com/cert/mysite.com.crt;
    ssl_certificate_key /var/www/mysite.com/cert/mysite.com.key;

    access_log /var/log/nginx/mysite.com.access.log rt_cache;
    error_log /var/log/nginx/mysite.com.error.log;

    root /var/www/mysite.com/htdocs;

    index index.php index.html index.htm;

    include common/php.conf;
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/mysite.com/conf/nginx/*.conf;
}

#2

Should you not add an additional server block like this to force http to https?:

server {
       listen         80;
       server_name    mysite.com www.mysite.com;
       return         301 https://$server_name$request_uri;
}

And also add something like this in your current server block?:

        # This forces every request after this one to be over HTTPS
        add_header Strict-Transport-Security "max-age=31536000";

#3

I added this and works. Thank you.

server {
       listen         80;
       server_name    mysite.com www.mysite.com;
       return         301 https://$server_name$request_uri;
}

#4