Welcome! Log In Create A New Profile

Advanced

Setting up basic nginx reverse proxy

Posted by frewsxcv 
Setting up basic nginx reverse proxy
May 21, 2011 02:34AM
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?

Loving nginx so far, thanks devs :-)
Tag
Re: Setting up basic nginx reverse proxy
June 06, 2011 05:16PM
Hello,
I think I can help you.
try this :
server {
listen 80;
server_name your_server_name;
access_log logs/server.access.log;
error_log logs/server.nginx_error.log;

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

location /some/extra/stuff/ {
proxy_pass http://127.0.0.1:8080/some/extra/stuff/;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}
Tag
Re: Setting up basic nginx reverse proxy
June 06, 2011 05:34PM
For me I have another problem.
I have two servers behind nginx but nginx seems to get only the first server in the config file.
I have this :

server_name_in_redirect off;


server {
listen 80;
server_name server1.domain.com;
access_log logs/server1.access.log;
error_log logs/server1.nginx_error.log;

location / {
proxy_pass http://server1.domain.com/;
}

location /server1/ {
proxy_pass http://server1.domain.com/;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

server {
listen 80;
server_name server2.domain.com;
access_log logs/server2.access.log;
error_log logs/lacie1.nginx_error.log;

location / {
proxy_pass http://server2.domain.com/;
}

location /server2/ {
proxy_pass http://server2.domain.com/;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

I don't understand why the second server is not active in the config file.
Please help me.
Thank you



Edited 1 time(s). Last edit at 06/06/2011 05:38PM by Tag.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready