How do I create a reverse proxy like Apache?

#1
Hi, on a shared server, I need to serve all requests to a URL (my.site.com/) through another local server. In Apache, I put:

<VirtualHost *:80>
ServerName my.site.com:80
DocumentRoot /path/to/files/
ProxyPass / http://127.0.0.1:port/
ProxyPassReverse / http://127.0.0.1:port/
</VirtualHost>

How do I implement this in litespeed? I'm on a shared host that uses Apache configs, so I can't go through litespeed's "Virtual Host" admin. I see the "Web Server" type of "External App," but seems to be no way to call it for a specific path.

Thanks
Sean DeNigris
 

mistwang

LiteSpeed Staff
#2
You need to have your shared server admin to create a "Web Server" external application with name "127.0.0.1 : port" exactly match the address used in ProxyPass at server level, then comment out "ProxyPass", "ProxyPassReverse", add rewrite rule instead

Code:
RewriteRule /(.*) http://127.0.0.1:port/$1 [p]
 

mistwang

LiteSpeed Staff
#4
Unfortunately, LiteSpeed does not rewrite URL in the response body.
It may not required as the backend server still see the original request with original host name, not 127.0.0.1 .
 
#6
I tried:
but it didn't rewrite the URL at all

After some experimentation, I made the app listen externally (for testing purposes only) and found that:
Redirected to the app.

However, I want an internal rewrite, not an external redirect, so I changed to "[p]," but I got a 500 Internal server error. It was not the app itself because I could see that it never received any http requests and there was nothing in the webserver's error log.

What do you think?
 

mistwang

LiteSpeed Staff
#7
Code:
RewriteRule (.*) http://127.0.0.1:port/$1 [p]
should work.
You have to remove the leading '/' if you use the rewrite rule in .htaccess.
 
Top