I'm trying to use Nginx as a reverse proxy in front of some web applications. Nginx seems to run fine, but the reverse proxy doesn't seem to function properly. I've been testing with a range of internal webapplications at our shop and none of them function behind Nginx as wished for (so I assume there's something wrong with my Nginx configuration).

The relevant configuration: ignore_invalid_headers on; keepalive_requests 100; limit_zone gulag $binary_remote_addr 5m; recursive_error_pages on; sendfile on; server_name_in_redirect off; server_tokens off;

    ## Proxy caching options  
    proxy_buffering           on;
    proxy_cache_min_uses      3000;
    proxy_cache_path          /usr/local/nginx/proxy_temp/ levels=1:2 keys_zone=cache:10m inactive=10m max_size=1000M;
    proxy_cache_valid         any 1m; 
    proxy_ignore_client_abort off;
    proxy_intercept_errors    on;
                                                          proxy_next_upstream       error timeout invalid_header;
    proxy_redirect            off;
    proxy_set_header          X-Forwarded-For $remote_addr;
    proxy_connect_timeout     60;
    proxy_send_timeout        60;
    proxy_read_timeout        60;
    proxy_buffer_size          4k;
    proxy_buffers              4 32k;
    proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size 64k;

    ## Virtual servers configuration
    server {
            listen       10080;
            access_log  /var/log/nginx/access.log main;
            error_log   /var/log/nginx/error.log;
            index       index.html;
            root        /usr/local/nginx/html;

            location / {
                proxy_pass                      http://somewebapp;
                     proxy_cache            cache;
                     proxy_cache_use_stale  error timeout invalid_header updating http_500 http_502 http_503 http_504;
                     proxy_ignore_headers   Expires Cache-Control;

                    proxy_set_header        Host            $host;
                    proxy_set_header        X-Real-IP       $remote_addr;
                    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_max_temp_file_size 0;
            }

            }
    }
}

How Nginx behaves depends on what's being proxied. For example: - www.google.com -> browser is redirected to www.google.com - ASP.NET website on IIS -> IIS gives an error it doesn't know the recognize the hostname of the Nginx system - plain old static website on Apache -> OK - app in Tomcat, enabled through Mod-JK on Apache -> browser timeout

I must be doing something terribly wrong but I don't know what. It's like Nginx is stuck between proxying and redirecting.

Any clues?

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.