<div>HI:</div>
<div> </div>
<div>Let me give a summary for my question, it is a long descrption. </div>
<div> </div>
<div> </div>
<div>1) My question is :</div>
<div>I try to setup the NGINX as a reverse-proxy to protect a WebServer. The topology is a VirtualHost.  </div>
<div><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://abc.com/" target="_blank">abc.com</a> |-----------[nginx reverse proxy] ------- |virtualhost] ----/abc     directory</div>
<div><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://123.com/" target="_blank">123.com</a> |                                                                       |--/123  directory</div>
<div> </div>
<div>[note] the virtualhost port is 80</div>
<div> </div>
<div>2) I got a configuration as the following:</div>
<div>   Add these in NGINX.conf</div>
<div>   server {<br>       server_name  <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://abc.com/" target="_blank">abc.com</a>;<br>       location / {<br>           proxy_pass  <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://123.com/abc/" target="_blank">http://123.com/abc/</a>;<br>
       }<br>   }<br>   server {<br>       server_name  <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://def.com/" target="_blank">def.com</a>;<br>       location / {<br>           proxy_pass  <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://123.com/def/" target="_blank">http://123.com/def/</a>;<br>
       }<br>   }</div>
<div> </div>
<div>3) When I do according to the above the configuration, I can not access the VirtualHost. </div>
<div>I sniff and get the following packet(in Server&#39;s side) </div>
<p>GET /<a href="http://abc.com">abc.com</a> HTTP/1.0<br>Host: <a href="http://abc.com">abc.com</a><br>X-Real-IP: 192.168.2.169<br>X-Forwarded-For: 192.168.2.169<br>Connection: close<br>Accept: */*<br>Accept-Language: zh-cn<br>
Pragma: no-cache<br>If-Modified-Since: Sun, 11 Oct 2009 08:53:36 GMT<br>If-None-Match: &quot;c8752c52504aca1:2b3&quot;<br>User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)<br>Proxy-Connection: Keep-Alive</p>
<p>HTTP/1.1 404 Not Found<br>Content-Length: 1308<br>Content-Type: text/html<br>Server: Microsoft-IIS/6.0<br>X-Powered-By: <a href="http://ASP.NET">ASP.NET</a><br>Date: Sun, 11 Oct 2009 09:19:44 GMT<br>Connection: close<br>
----------------------------------------------------------------------------------------------------------<br>Case 2. Access from 192.168.2.169-&gt;192.168.10.169(web server) *BYPASS* the<br>NGINX revers proxy</p>
<p>GET / HTTP/1.1<br>Accept: */*<br>Accept-Language: zh-cn<br>Accept-Encoding: gzip, deflate<br>If-Modified-Since: Sun, 11 Oct 2009 08:53:36 GMT<br>If-None-Match: &quot;c8752c52504aca1:2b3&quot;<br>User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)<br>
Host: <a href="http://abc.com">abc.com</a><br>Connection: Keep-Alive</p>
<div>HTTP/1.1 200 OK<br>Content-Length: 248<br>Content-Type: text/html<br>Content-Location: <a href="http://abc.com/index.htm">http://abc.com/index.htm</a><br>Last-Modified: Sun, 11 Oct 2009 08:53:36 GMT<br>Accept-Ranges: bytes<br>
ETag: &quot;c8752c52504aca1:2c1&quot;<br>Server: Microsoft-IIS/6.0<br>X-Powered-By: <a href="http://ASP.NET">ASP.NET</a><br>Date: Sun, 11 Oct 2009 09:19:34 GMT</div>
<div>--------------------------------------------------------------------------------------------</div>
<div>At present, I still don&#39;t know how to configure Reverse-Proxy for VirtualHost. </div>
<div> </div>
<div>please give me a help. </div>
<div> </div>
<div>thanks </div>
<div>NextHop</div>
<div> </div>
<div><br> </div>
<div><span class="gmail_quote">On 10/11/09, <b class="gmail_sendername">Igor Sysoev</b> &lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Sun, Oct 11, 2009 at 05:55:35PM +0800, quan nexthop wrote:<br><br>&gt; Sorry later feedback because of the bussiness trip.<br>
&gt;<br>&gt; I configured it according to Igor Sysoev&#39;s advice, but it failed.<br>&gt; I sniff in the webserver&#39;s side, I found the request message is stranger.<br>&gt; ----------------------------------------------------------------<br>
&gt; Case1:  Access from 192.168.2.169-&gt;192.168.10.169(web server) *VIA* NGINX<br>&gt; reverse proxy.<br>&gt;<br>&gt; GET /<a href="http://abc.com">abc.com</a> HTTP/1.0<br>&gt; Host: <a href="http://abc.com">abc.com</a><br>
&gt; X-Real-IP: 192.168.2.169<br>&gt; X-Forwarded-For: 192.168.2.169<br>&gt; Connection: close<br>&gt; Accept: */*<br>&gt; Accept-Language: zh-cn<br>&gt; Pragma: no-cache<br>&gt; If-Modified-Since: Sun, 11 Oct 2009 08:53:36 GMT<br>
&gt; If-None-Match: &quot;c8752c52504aca1:2b3&quot;<br>&gt; User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)<br>&gt; Proxy-Connection: Keep-Alive<br>&gt;<br>&gt; HTTP/1.1 404 Not Found<br>&gt; Content-Length: 1308<br>
&gt; Content-Type: text/html<br>&gt; Server: Microsoft-IIS/6.0<br>&gt; X-Powered-By: <a href="http://ASP.NET">ASP.NET</a><br>&gt; Date: Sun, 11 Oct 2009 09:19:44 GMT<br>&gt; Connection: close<br>&gt; ----------------------------------------------------------------------------------------------------------<br>
&gt; Case 2. Access from 192.168.2.169-&gt;192.168.10.169(web server) *BYPASS* the<br>&gt; NGINX revers proxy<br>&gt;<br>&gt; GET / HTTP/1.1<br>&gt; Accept: */*<br>&gt; Accept-Language: zh-cn<br>&gt; Accept-Encoding: gzip, deflate<br>
&gt; If-Modified-Since: Sun, 11 Oct 2009 08:53:36 GMT<br>&gt; If-None-Match: &quot;c8752c52504aca1:2b3&quot;<br>&gt; User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)<br>&gt; Host: <a href="http://abc.com">abc.com</a><br>
&gt; Connection: Keep-Alive<br>&gt;<br>&gt; HTTP/1.1 200 OK<br>&gt; Content-Length: 248<br>&gt; Content-Type: text/html<br>&gt; Content-Location: <a href="http://abc.com/index.htm">http://abc.com/index.htm</a><br>&gt; Last-Modified: Sun, 11 Oct 2009 08:53:36 GMT<br>
&gt; Accept-Ranges: bytes<br>&gt; ETag: &quot;c8752c52504aca1:2c1&quot;<br>&gt; Server: Microsoft-IIS/6.0<br>&gt; X-Powered-By: <a href="http://ASP.NET">ASP.NET</a><br>&gt; Date: Sun, 11 Oct 2009 09:19:34 GMT<br>&gt; -----------------------------------------------------------------------------------------------------<br>
&gt; The case 1 is failed. If I bypass the NGINX revers-proxy, it success.<br>&gt; I marked with RED, there are some difference. I can not dig into deep.<br>&gt; please help me for the issue.<br><br>Then I do not understand, what you meant by this:<br>
<br><a href="http://abc.com">abc.com</a> |----[nginx reverse proxy] -- |virtualhost] --/abc directory <a href="http://123.com">123.com</a>|<br>|--/123  directory<br><br>&gt; I pasted the configuration as following:<br>&gt; -------------------------------------------------------------------------------<br>
&gt;  47   server {<br>&gt;  48       listen 8080;<br>&gt;  49       server_name <a href="http://abc.com">abc.com</a>;<br>&gt;  50       access_log /var/log/nginx/access.log;<br>&gt;  51<br>&gt;  52       location / {<br>
&gt;  53           proxy_pass <a href="http://192.168.10.169/abc.com">http://192.168.10.169/abc.com</a>;<br>&gt;  54           proxy_redirect default;<br>&gt;  55           proxy_set_header Host $host;<br>&gt;  56           proxy_set_header  X-Real-IP  $remote_addr;<br>
&gt;  57           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>&gt;  58           client_max_body_size 50m;<br>&gt;  59           client_body_buffer_size 256k;<br>&gt;  60      }<br>&gt;  61  }<br>&gt;  62  server {<br>
&gt;  63       listen 8080;<br>&gt;  64       server_name <a href="http://def.com">def.com</a>;<br>&gt;  65       access_log /var/log/nginx/access.log;<br>&gt;  66<br>&gt;  67       location / {<br>&gt;  68           proxy_pass <a href="http://192.168.10.169/def.com">http://192.168.10.169/def.com</a>;<br>
&gt;  69           proxy_redirect default;<br>&gt;  70           proxy_set_header Host $host;<br>&gt;  71           proxy_set_header  X-Real-IP  $remote_addr;<br>&gt;  72           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>
&gt;  73           client_max_body_size 50m;<br>&gt;  74           client_body_buffer_size 256k;<br>&gt;  75     }<br>&gt;  76  }<br>&gt;<br>&gt;<br>&gt; thanks<br>&gt; NextHop<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On 10/6/09, Igor Sysoev &lt;<a href="mailto:is@rambler-co.ru">is@rambler-co.ru</a>&gt; wrote:<br>
&gt;<br>&gt; &gt; On Mon, Oct 05, 2009 at 04:00:23PM +0800, quan nexthop wrote:<br>&gt; &gt;<br>&gt; &gt; &gt; Hi all:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; I try to setup the NGINX as a reverse-proxy to protect several<br>
&gt; &gt; webservers,<br>&gt; &gt; &gt; which lots of websites are running on. Yes, it is a virtual host :)<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; <a href="http://abc.com">abc.com</a> |-----------[nginx reverse proxy] ------- |virtualhost] ----/abc<br>
&gt; &gt; &gt; directory<br>&gt; &gt; &gt; <a href="http://123.com">123.com</a>|<br>&gt; &gt; &gt; |--/123  directory<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; [note] the virtualhost port is 80.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; I go through the <a href="http://wiki.nginx.net">wiki.nginx.net</a> and can not find any configuration<br>
&gt; &gt; related<br>&gt; &gt; &gt; with the topology.<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; Any one can paste a configuration for such case?<br>&gt; &gt; &gt; how can I distinguish the different server in one listening port?<br>
&gt; &gt;<br>&gt; &gt; Probably you need<br>&gt; &gt;<br>&gt; &gt;    server {<br>&gt; &gt;        server_name  <a href="http://abc.com">abc.com</a>;<br>&gt; &gt;        location / {<br>&gt; &gt;            proxy_pass  <a href="http://123.com/abc/">http://123.com/abc/</a>;<br>
&gt; &gt;        }<br>&gt; &gt;    }<br>&gt; &gt;<br>&gt; &gt;    server {<br>&gt; &gt;        server_name  <a href="http://def.com">def.com</a>;<br>&gt; &gt;        location / {<br>&gt; &gt;            proxy_pass  <a href="http://123.com/def/">http://123.com/def/</a>;<br>
&gt; &gt;        }<br>&gt; &gt;    }<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; --<br>&gt; &gt; Igor Sysoev<br>&gt; &gt; <a href="http://sysoev.ru/en/">http://sysoev.ru/en/</a><br>&gt; &gt;<br>&gt; &gt;<br><br>--<br>Igor Sysoev<br>
<a href="http://sysoev.ru/en/">http://sysoev.ru/en/</a><br><br></blockquote></div><br>