Multiple site configuration
reallfqq-nginx at yahoo.fr
Mon May 13 16:58:48 UTC 2013
The problem I see is you try to address the process of requests differently
whether from inside your network or from the outside.
You may already solve the problem of your outside interface easily with server
names <http://nginx.org/en/docs/http/server_names.html> (knowing how nginx
processes a request <http://nginx.org/en/docs/http/request_processing.html>),
listening for 'localhost', 'site2.eu' and 'sub.site.eu'.
What's uncommon is your way of addressing local websites, all locations
(/site2, /subsite2) inside a unique server listening on a local IP address.
That breaks the paradigm and thus becomes incompatible with the previous
The 'Mixed name-based and IP-based server names' section of the How Nginx
processes a request
provides you with intelligence on how things may be done:
listen 192.168.x.x; # Default port is 80 when not specified
# Not sure whether or not you can use CIDR notation here, such as
# No 'server_name' directive here, default is empty, which means all
request for this IP on port 80 without another server matching the
server_name will end up here
# Content of site 1 here
listen 80; # Default listens on all addresses/interfaces when only a
port is specified
server_name site2.eu; # Use location redirection to remove the www in
host, see http://forum.nginx.org/read.php?2,238910,238911#msg-238911
# Content of site 2 here
# Content of site 3 here
site2.eu and sub.site2.eu will be accessible from inside/outside your
network using the same domain name.
site 1 will only be accessible from the 192.168.x.x address which shouldn't
be routed from outside your network, thus making it locally accessible
only. You may add whatever server name you wish to it, it will stick to
Another addendum: document on how Nginx choose its default server for a
particular request in How nginx processes a
how nginx will address special cases.
Hope I helped.
On Mon, May 13, 2013 at 12:26 PM, guillaumeserton <nginx-forum at nginx.us>wrote:
> I would like to set nginx to use several website, and that they are
> reachable for some of them with a domain name or in localhost.
> Site1: only accessible on localhost with 192.168.x.x/site1 (root:
> Site2: accessible accessible on site2.eu domain and also on localhost with
> 192.168.x.x/site2 (root: /var/www/site2)
> Site3: accessible on the subdomain sub.site2.eu and also on localhost with
> 192.168.x.x/subsite2 (root: /var/www/subsite2)
> I have set two sites (site2 and site3) on my configuration and reachable
> with domain and subdomain. But i can't reach them locallly with the
> ipaddress/nameofsite. I have only one site accessible directly under my
> local ip address.
> So, currently i have:
> Site2 (var/www/site2: reachable with his domain site2.eu or www.site2.euand
> also on the local ip 192.168.x.x
> SIte3 (var/www/site3: reachable with the domain sub.site2.eu. Otherwise i
> can't reach him locally. I would like to reach him with 192.168.x.x/site3
> Thanks for your help.
> Posted at Nginx Forum:
> nginx mailing list
> nginx at nginx.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx