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