I have around 1300vhosts in one nginx conf file. All with the following layout (they are listed after each other in the vhost file).
Now my problem is that sometimes my browser redirects site2 to site1. For some reason, while the domain names don't event match.
It looks like nginx is always redirecting to the first site in the vhosts file.
Somebody that know what this problem can be?
server {
listen 80;
server_name site1.com;
rewrite ^(.*) http://www.site1.com$1 permanent;
}
server {
listen 80;
root /srv/www/site/public_html/src/public/;
error_log /srv/www/site/logs/error.log;
index index.php;
server_name www.site1.com;
location / {
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}
location ~ .(php|phtml)$ {
try_files $uri $uri/ /index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/site/public_html/src/public$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
server {
listen 80;
server_name site2.com;
rewrite ^(.*) http://www.site2.com$1 permanent;
}
server {
listen 80;
root /srv/www/site/public_html/src/public/;
error_log /srv/www/site/logs/error.log;
index index.php;
server_name www.site2.com;
location / {
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}
location ~ .(php|phtml)$ {
try_files $uri $uri/ /index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/site/public_html/src/public$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
EDIT Maybe another thing to mention is that, I reload all this vhosts every 2 minutes with nginx -s reload.
On the first tests it looks like the redirection only happens when reloading... Going to do some more tests, but this could be helpful..