Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to use nginx as a proxy to a Tomcat non-root app but am having problems to do that. This is the code that I use:

location / {
    proxy_pass         http://127.0.0.1:8080/app_v1.1.0/;
        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;
        proxy_max_temp_file_size 0;

        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;
    }

Now, this works ok for the app login screen but doesn't work for anything beyond that. After I login, the login page comes back so I think something is wrong with this kind of proxying, some kind of rewrite is obviously missing.

If I change it to something like:

location / {
    proxy_pass         http://127.0.0.1:8080/;
}

or:

location /app_v1.1.0 {
    proxy_pass         http://127.0.0.1:8080/app_v1.1.0
}

Then it works but i have to access my app via 'http:///app_v1.1.0' ... Can this be circumvented somehow?

Thank you.

share|improve this question
    
Perhaps this will answer your question? stackoverflow.com/questions/18936753/… –  Mr Nil Feb 4 at 19:08
    
I've tried it already, but that rewrite doesn't seem to help :-/ Maybe the application is broken in some way. I made a temporary fix by renaming app.war to ROOT.war and proxying '/' although I would like to do it the other way. –  Jakov Sosic Feb 5 at 22:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.