Nginx reverse proxy with IP-Based vhosts apache

Hi,

I’m looking for comments on my nginx.conf file. I am using nginx to
serve
some static content and proxy to apache for some other requests however
I
think there is something wrong with my proxypass settings.

If I use apache’s name based virtual hosts everything works out great,
however if I use IP based virtual hosts, apache does not direct to the
right
virtual host, instead just defaulting to the main Document Root. I can’t
seem to find an answer on Google anywhere, so any feedback is greatly
appreciated (relevant part of nginx.conf below).

    location / {
        proxy_pass         http://127.0.0.1:8080/;
        proxy_redirect     off;

        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For 

$proxy_add_x_forwarded_for;

        client_max_body_size       10m;
        client_body_buffer_size    128k;

        proxy_connect_timeout      90;
        proxy_send_timeout         90;
        proxy_read_timeout         90;

        proxy_buffer_size          4k;
        proxy_buffers              4 32k;
        proxy_busy_buffers_size    64k;
        proxy_temp_file_write_size 64k;
    }

Hello,

this seems more an apache issue.
Have you got a proper NameVirtualHost directive ?
(e.g. NameVirtualHost *:8080 )

I want to use IP-based virtual hosting (not name based with
NameVirtualHost)
for purposes of SSL

“Jamie Q.” wrote:

If I use apache’s name based virtual hosts everything works out great,
however if I use IP based virtual hosts, apache does not direct to
the right virtual host, instead just defaulting to the main Document
Root. I can’t seem to find an answer on Google anywhere, so any
feedback is greatly appreciated (relevant part of nginx.conf below).

Hi,
for name based virtual hosts, a web server uses the request Host header
to decide which virtual host to dispatch to.
When you use IP based virtual hosts, you need to set them up to listen
on different ports and/or ip addresses. If you don’t, apache has no way
of knowing which virtual host is the right one, just like you describe.

I am aware of this, however the problem I am having is that apache can
not
differentiate because it sees everything coming from nginx as
127.0.0.1(localhost). Thus the only way it works is if I do the
following…
<VirtualHost 127.0.0.1:8080>

When in reality I want something like this…

<VirtualHost 77.77.66.66:8080>

<VirtualHost 77.77.66.65:8080>

<VirtualHost 77.77.66.64:8080>

Which I cannot do without having some way to get the IP from behind
nginx.

~Jamie