Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Edit: Looks like this has nothing to do with nginx reload. I disabled the cron and still facing this issue. It's just randomly. Anybody an idea?

I have an nginx setup that has around 460 vhosts (all seperate files). Every 2 minutes I do an nginx reload to load new vhosts. But looks like I'm facing a problem now.

Could it be that while reloading nginx I get an vhost mismatch?

Example: I load up www.mysite.com and it redirects to www.yoursite.com.

I'm facing this problem often (not always). Anybody any idea?

My vhosts looks like this

server {
listen   80; 

root /srv/www/core/public_html/src/public/;
error_log /srv/www/core/logs/error.log;
index index.php;

server_name www.site.com site.com;

location / {
    if (!-e $request_filename) {
        rewrite ^.*$ /index.php last;
    if ($host != 'www.site.com' ) {
        rewrite ^/(.*)$ http://www.site.com/$1 permanent;

location ~ .(php|phtml)$ {
    fastcgi_param SCRIPT_FILENAME /srv/www/core/public_html/src/public$fastcgi_script_name;
    fastcgi_index index.php;
    include fastcgi_params;


share|improve this question
What do you mean by "vhost mismatch"? –  VBart Nov 28 '12 at 3:39
I load up www.mysite.com and it redirects to www.yoursite.com. –  Ward Loockx Nov 28 '12 at 7:50
There are two the most possible reasons: 1. you configured it that way, 2. it's done by your php. Also, you should remove these ifs from you configuration, because If Is Evil and you do not need them. –  VBart Nov 28 '12 at 11:15
See: nginx.org/en/docs/http/converting_rewrite_rules.html You should use separate server blocks and the try_files directive. –  VBart Nov 28 '12 at 11:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.