Is it possible to put a redirect in 1 single server block to redirect any https (port 443) that do not have www to https://www...? I don't want to have to put that redirect in every single server block for each specific domain.
I currently have this, but it is not allowing nginx (in Windows) to start up:
server {
listen 443 ssl;
server_name _;
if ($host !~* ^www\.(.*)$) {
return 301 https://www.$host$request_uri;
}
}
server {
listen 443 ssl;
server_name example.com;
# ...
}
server {
listen 443 ssl;
server_name anotherexample.com;
# ...
}