Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Please help me in URLRewrite using upstream LB servers

$
0
0
Hi,

I am new to NGINX and trying to learn at work. I have a requirement, where my web applications are deployed into the two servers at same ports. I am using tomcat server and I want my url args are preserved in final URL.
Example:
Service 1 : http://server1.com:8000/login/blah/blah and http://server2.com:8000/login/blah/blah
Service 2 : http://server1.com:8001/account/blah/blah and http://server2.com:8001/account/blah/blah
Service 3 : http://server1.com:8002/user/blah/blah and http://server2.com:8002/user/blah/blah

and so on. I have 20 services are deployed like above. I am trying to front them with nginx as load balencer and using url rewrite based on the URL context.

Can one help me to resolve the issue. I tried for last 6 hours but nothing is working. I am able solve using urlrewrite but not with proxypass.

nginx.conf file:

#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
upstream loginservice {
least_conn;
server 127.0.0.1:8000;
server 127.0.0.2:8000;
server 127.0.0.3:8000;
}
upstream accountservice {
least_conn;
server 127.0.0.1:8001;
server 127.0.0.2:8001;
server 127.0.0.3:8001;
}
server {
listen 9000;
server_name myserver.com;
rewrite_log on;
location /account{
rewrite ^ $scheme://localhost$request_uri permanent;
proxy_pass http://loginservice;
}
location /logon {
rewrite ^ $scheme://localhost$request_uri permanent;
proxy_pass http://accountservice;
}
}
}

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>