Hello,
I would like to ask for some help with the following Nginx configuration, so that URLs such as https://www.mywebsite.com get rewritten as https://mywebsite.com. I am currently using the following configuration:
server {
server_name www.mywebsite.com;
return 301 $scheme://mywebsite.com$request_uri;
}
server {
listen 80;
server_name mywebsite.com;
# Some more settings...
}
server {
listen 443 ssl;
server_name mywebsite.com;
ssl_certificate path_to_ssl_certificate;
ssl_certificate_key path_to_ssl_certificate_key;
# Some more settings...
}
In case that matters, the certificate I am using is a wildcard SSL certificate that was self-signed using OpenSSL on the server itself (Ubuntu 12.04). What is happening is that www.mywebsite.com correctly redirects to mywebsite.com, but https://www.mywebsite.com does not redirect to https://www.mywebsite.com (i.e., the www still appears when viewing the page in a browser). What can I be doing wrong?