HTTP to HTTPS Using Nginx
I've configured HTTP to HTTPS redirect in my /etc/nginx/sites-available/default file. Its as below:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com
return 301 https://$servername$requesturi;
}
server {
SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-example.com.conf;
include snippets/ssl-params.conf;
. . .
My problem is that everytime I try to go to "
Thank you for your help!
1 Reply
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
You should probably put a server_name line inside the https server block as well.