Unfortunately, my work requires me to use Apache Tomcat. The Tomcat application is running on http://127.0.0.1:8080/. I'd like to get a reverse proxy going so I can have http://mydomain.com/tomcat/some/extra/stuff proxy from http://127.0.0.1:8080/some/extra/stuff. This is what I'm trying so far:

location /tomcat {
    proxy_pass http://127.0.0.1:8080;
    rewrite ^/tomcat(/.*) $1 break;
}

This results in http://mydomain.com/tomcat/meow/cat redirecting to http://mydomain.com/meow/cat which is not what I want. Any ideas?

link|improve this question
feedback

1 Answer

You don't need the rewrite rule, that config will map domain.com/tomcat/ to http://127.0.0.1:8080/ so you don't need to rewrite the directory

link|improve this answer
I want 127.0.0.1:8080/whatever to be accessed by mypublicip/tomcat/whatever rather than mypublicip/whatever – Corey Farwell May 27 '11 at 5:00
Yes, that will work fine, you don't need rewrite rules. Anything with a sub-directory of /tomcat will be proxied. site/tomcat/folder/file.html will map to 127[...]/folder/file.html – sam May 27 '11 at 5:34
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.