Hi!

I played around with it a little bit and found out the following:

server_name in a vhost entry doesn't really guarantee that only requests
coming from specified domain will get served by that vhost.

For example (supposing that domain1.com, www.domain1.com, domain2.com,
www.domain2.com all point to the machine where nginx is running):

http {
    server {
        listen          80;
        server_name     www.domain1.com;

        location / {
            index index.html;
            root  /var/www/domain1;
        }
    }

    server {
        listen          80;
        server_name     www.domain2.com;

        location / {
            index index.html;
            root  /var/www/domain2;
        }
    }
}

- if you go to domain2.com (without www), you'll land in
/var/www/domain1 (one!)
- If you delete a vhost for domain2, then you'll land in
/var/www/domain1 when going to www.domain2.com or domain2.com

So it seems that if there is no exact match, it just takes the first
vhost. Maybe this is well known, but it's still confusing. I think this
is not ideal implementation. I tried to do the following:

http {
    server {
        listen          domain1.com:80;
        server_name     domain1.com alias www.domain1.com;

        location / {
            index index.html;
            root  /var/www/domain1;
        }
    }

    server {
        listen          domain2.com:80;
        server_name     domain2.com alias www.domain2.com;

        location / {
            index index.html;
            root  /var/www/domain2;
        }
    }
}

That of course solves the "www" problem, but I still don't agree that it
just picks one vhost.. it should display an error!

The second problem remains, so if I delete the vhosts entry for domain2,
I still land in /var/www/domain1 when going to (www.)domain2.com. It
seems that listen somedomain.com:80; doesn't do anything, but it was a
nice try :)

Another important issue is that when sending HUP (kill 0) signal to
nginx for reloading configuration (= saying /etc/init.d/nginx reload)
and there is a syntactical error in the conf file, you won't get any
error message. It just won't reload the new script.

If you stop and then try to start the server, you will get something
like:
16326#0: directive "server" has no opening "{" in
/usr/local/nginx/conf/nginx.conf:67

Maybe there is a way to check the conf file like in apache. The perfect
solution would be if reload signal would let you know if there were any
issues with the file..

That's it.. hope it helps someone and also that you reply with your
thoughts about those two issues.. Overall I like nginx very much, but I
just want to learn exactly how it works.

Thank you,
David
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Deploying Rails" group.
To post to this group, send email to rubyonrails-deployment@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-deployment?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to