NginX problem with Reverse Proxy'ing

Victor siberiano.delta at gmail.com
Sat Apr 10 19:36:19 MSD 2010


Hi, I have a little problem that's driving me crazy since 4 days. I'm trying
to create a server with NginX (0.8.35) serving static content (PDF files
mainly) as frontend and Apache2 as backend processing the PHP files,
actually I'm working only with basic PHP (phpinfo()) files for testing
purposes (this isn't my production machine, only a
pre-production-kind-machine. Apache is running in 127.0.0.1:8080

When I'm trying to proxy the PHP to Apache is issuing a 301 Redirection (i
tested it with cURL from another host, and giving a network error in IE8 and
Chrome.
Here I include the config files loaded in Nginx:

Nginx.conf
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-available/*;
}


sites-available/www

server {
listen   80 default;
server_name  blog.foo.com;

access_log  /var/log/nginx/foo.access.log;
error_log /var/log/nginx/foo.error.log;

location / {
root   /var/www2;
index index.php;
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/conf.d/proxy.conf;
}
}

conf.d/proxy.conf

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   16k;
proxy_buffers       32   16k;
proxy_busy_buffers_size 64k;




Now the -i from cURL in blog.foo.com/index.php
HTTP/1.1 301 Moved Permanently
Server: nginx/0.8.35
Date: Sat, 10 Apr 2010 15:34:45 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.2.10-2ubuntu6
X-Pingback: http://127.0.0.1:81/xmlrpc.php
Location: http://blog.foo.com:81/
Vary: Accept-Encoding
Content-Length: 0

snip from log file
"GET /index.php HTTP/1.1" 301 0 "-" "curl/7.19.5 (i486-pc-linux-gnu)
libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20100410/adb272ec/attachment.html>


More information about the nginx mailing list