Configurations strangeness - mistake or bug?

Gábor Kövesdán gabor at kovesdan.org
Sun Nov 16 00:22:04 UTC 2014


Hi,

I'm facing a strange issue configuring virtual hosts on a server. I 
don't see any misconfiguration yet it does not work as I expect it. I'd 
like to ask for your help in debugging this. If the configuration is 
incorrect, we can improve the documentation so that others do not commit 
this mistake or if there is a bug in nginx, this could help in fixing it.

The problem is that I have two main domains, let's refer to them as 
foobar.com and foo-bar.com (yes, one of them has a hyphen) and I want to 
set up webmail and phpmyadmin canonical names that serve the 
corresponding service and only allows https access. When unencrypted 
http is used, it should redirect to the https version. The corresponding 
part of the configuration is pasted below. The problem with this is that 
it does not work as expected.
In Chrome, http://phpmyadmin.foo-bar.com erroneously redirects to 
https://webmail.foobar.com, while http://phpmyadmin.foobar.com redirects 
properly. The rest is fine.
In Firefox, surprisingly the redirection is different. 
http://phpmyadmin.foo-bar.com works properly but 
http://phpmyadmin.foobar.com redirects to https://webmail.foobar.com. 
The rest works.

I cannot figure out where the wrong redirection comes from and why it 
behaves differently in different browsers. Do you have any guess? Or any 
suggestions how I could debug this?

Thanks in advance,
Gábor Kövesdán


server {
  listen [::]:80;
  server_name webmail.foobar.com www.webmail.foobar.com
   webmail.foo-bar.com www.webmail.foo-bar.com;
  return 301 https://webmail.foobar.com;
}

server {
  listen [::]:80;
  server_name phpmyadmin.foobar.com www.phpmyadmin.foobar.com
   phpmyadmin.foo-bar.com www.phpmyadmin.foo-bar.com;
  return 301 https://phpmyadmin.foobar.com;
}

server {
  listen [::]:443 ssl;
  server_name webmail.foobar.com www.webmail.foobar.com
   webmail.foo-bar.com www.webmail.foo-bar.com;

  root /usr/local/www/squirrelmail;

  error_log /var/log/nginx/foobar.com-error.log error;
  access_log /var/log/nginx/foobar.com-access.log main;

  include php.conf;
}

server {
  listen [::]:443 ssl;
  server_name phpmyadmin.foobar.com www.phpmyadmin.foobar.com
   phpmyadmin.foo-bar.com www.phpmyadmin.foo-bar.com;

  root /usr/local/www/phpMyAdmin;

  error_log /var/log/nginx/foobar.com-error.log error;
  access_log /var/log/nginx/foobar.com-access.log main;

  include php.conf;
}




More information about the nginx mailing list