It's about two subdomains. The first one (www) should be accessed via http. The second one (cloud) should be accessed via https.
These are the relevant parts of my entries:
server {
listen 80;
server_name cloud.example.de;
rewrite ^ https://$server_name$request_uri? permanent; # enforce https
}
server {
listen 443 ssl;
server_name cloud.example.de;
root /home/user/web/cloud;
}
server {
listen 80;
server_name www.example.de;
root /home/user/web/cms;
#etc.
}
When I now call http://cloud.example.de I am redirected to https://cloud.example.de, fine.
But when I call http://www.example.de I am also redirected, to https://www.example.de, which leads me to the content of cloud.example.com, because this is the only servername set as used by port 443.
There is no entry in the access-log of the www-subdomain.
There is another subdomain pointing to a phpPgAdmin. This I can access as normal, it's not rewritten.
server {
listen 80;
server_name pgsql.example.de;
root /home/user/web/phppgadmin;
#etc
}
What is missing? The rewrite should be only done if the servername matches cloud.example.de.
And is there a relevance in the order of the server entries or does it not matter?
Using nginx 0.8.54 on Ubuntu 11.04.