<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">The problem I see is you try to address the process of requests differently whether from inside your network or from the outside.<br></div>
<div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">You may already solve the problem of your outside interface easily with <a href="http://nginx.org/en/docs/http/server_names.html">server names</a> (knowing <a href="http://nginx.org/en/docs/http/request_processing.html">how nginx processes a request</a>), listening for 'localhost', '<a href="http://site2.eu">site2.eu</a>' and '<a href="http://sub.site.eu">sub.site.eu</a>'.<br>
<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">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.<br>
<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">The 'Mixed name-based and IP-based server names' section of the <a href="http://nginx.org/en/docs/http/request_processing.html">How Nginx processes a request</a> document provides you with intelligence on how things may be done:<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">server {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> listen 192.168.x.x; # Default port is 80 when not specified<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> # Not sure whether or not you can use CIDR notation here, such as 192.168/16;<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
# 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<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
<br> # Content of site 1 here<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">}<br><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">server {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
listen 80; # Default listens on all addresses/interfaces when only a port is specified<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> server_name <a href="http://site2.eu">site2.eu</a>; # Use location redirection to remove the www in host, see <a href="http://forum.nginx.org/read.php?2,238910,238911#msg-238911">http://forum.nginx.org/read.php?2,238910,238911#msg-238911</a><br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><br> # Content of site 2 here<br></div>}<br><br><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">server {<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
listen 80;</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"> server_name <a href="http://sub.site2.eu">sub.site2.eu</a>;<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">
<br> # Content of site 3 here<br></div>}<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><a href="http://site2.eu">site2.eu</a> and <a href="http://sub.site2.eu">sub.site2.eu</a> will be accessible from inside/outside your network using the same domain name.<br>
</div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">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.<br>
<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Another addendum: document on how Nginx choose its default server for a particular request in <a href="http://nginx.org/en/docs/http/request_processing.html">How nginx processes a request</a> to learn how nginx will address special cases.<br>
<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Hope I helped.<br></div><div class="gmail_extra"><div><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div>
<br><br><div class="gmail_quote">On Mon, May 13, 2013 at 12:26 PM, guillaumeserton <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
<br>
I would like to set nginx to use several website, and that they are<br>
reachable for some of them with a domain name or in localhost.<br>
<br>
Example:<br>
Site1: only accessible on localhost with 192.168.x.x/site1 (root:<br>
/var/www/site1)<br>
Site2: accessible accessible on <a href="http://site2.eu" target="_blank">site2.eu</a> domain and also on localhost with<br>
192.168.x.x/site2 (root: /var/www/site2)<br>
Site3: accessible on the subdomain <a href="http://sub.site2.eu" target="_blank">sub.site2.eu</a> and also on localhost with<br>
192.168.x.x/subsite2 (root: /var/www/subsite2)<br>
<br>
I have set two sites (site2 and site3) on my configuration and reachable<br>
with domain and subdomain. But i can't reach them locallly with the<br>
ipaddress/nameofsite. I have only one site accessible directly under my<br>
local ip address.<br>
<br>
So, currently i have:<br>
<br>
Site2 (var/www/site2: reachable with his domain <a href="http://site2.eu" target="_blank">site2.eu</a> or <a href="http://www.site2.eu" target="_blank">www.site2.eu</a> and<br>
also on the local ip 192.168.x.x<br>
SIte3 (var/www/site3: reachable with the domain <a href="http://sub.site2.eu" target="_blank">sub.site2.eu</a>. Otherwise i<br>
can't reach him locally. I would like to reach him with 192.168.x.x/site3<br>
<br>
<br>
Thanks for your help.<br>
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,239147,239147#msg-239147" target="_blank">http://forum.nginx.org/read.php?2,239147,239147#msg-239147</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br></div></div>