Reverse proxy question

#1
Hi,

Trying the enterprise 2cpu atm. Trying to replicate a nginx/apache combo which utilises some reverse proxying of folders to multiple app servers.

So www.example.com/shop goes to another php shop vm server. .com/news to a rails app, you get the idea.

Each of these 'proxied' apps run thinking they are the root i.e. they work on /.

Nginx can reverse proxy these fine and I believe litespeed can too. I've set up the proxy as webserver in external app etc and it does indeed proxy, but retains the folder/uri.

The nginx snippet is:

Code:
upstream nginx_shop_srv {
  server 10.0.0.2 fail_timeout=0;
  server 10.0.0.3 fail_timeout=0 backup;
}

location ^~ /shop {
        proxy_pass http://nginx_shop_srv/;
        break;
  }
The key being the additional slash on the proxy pass, which replaces the uri with the proxy loc.

So to restate/clarify, I'm looking for example.com/shop/products.php to be seen on the target proxied app server as a request for 10.0.0.2/products.php from litespeed.

I've tried a few combinations of trailing slash and re-read proxy docs. Nothing lept out, what did I miss?

Thanks for reading.
 

NiteWave

Administrator
#2
try rewriterule

assume it's native vhost. vhost->Rewrite
ReriteRule /shop/(.*)$ http://nginx_shop_srv/$1 [P]

define an external app nginx_shop_srv as web server,
Name:nginx_shop_srv
Address: 10.0.0.2:80
 
#3
Rewrite, I never thought to go that way, ok super thank you.

Going to have to give some time back to learning mod_rewrite I suspect :)

I modified it slightly to permit /shop working.
Code:
RewriteRule /shop(.*)$ http://nginx_shop_srv/$1 [P]
Thanks.
 
Top