Welcome! Log In Create A New Profile

Advanced

Re: Multiple site configuration

B.R.
May 13, 2013 01:00PM
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
work.


The 'Mixed name-based and IP-based server names' section of the How Nginx
processes a request
http://nginx.org/en/docs/http/request_processing.htmldocument
provides you with intelligence on how things may be done:
server {
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
192.168/16;

# 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
}

server {
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
}

server {
listen 80;
server_name sub.site2.eu;

# 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
that network.

Another addendum: document on how Nginx choose its default server for a
particular request in How nginx processes a
requesthttp://nginx.org/en/docs/http/request_processing.htmlto learn
how nginx will address special cases.

Hope I helped.
---
*B. R.*


On Mon, May 13, 2013 at 12:26 PM, guillaumeserton <nginx-forum@nginx.us>wrote:

> Hello,
>
> 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.
>
> Example:
> Site1: only accessible on localhost with 192.168.x.x/site1 (root:
> /var/www/site1)
> 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:
> http://forum.nginx.org/read.php?2,239147,239147#msg-239147
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Multiple site configuration

guillaumeserton May 13, 2013 12:26PM

Re: Multiple site configuration

B.R. May 13, 2013 01:00PM

Re: Multiple site configuration

Francis Daly May 13, 2013 05:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready