How do I create a reverse proxy like Apache?

Discussion in 'Apache Migration/Compatibility' started by lotusone, Apr 17, 2009.

  1. lotusone

    lotusone New Member

    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
  2. mistwang

    mistwang LiteSpeed Staff

    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] 
  3. lotusone

    lotusone New Member

    Thanks! Does that rewrite do the function of both the ProxyPass and the ProxyPassReverse?
  4. mistwang

    mistwang LiteSpeed Staff

    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 .
  5. lotusone

    lotusone New Member

    Ok, I'll give it a shot. Thanks :)
  6. lotusone

    lotusone New Member

    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?
  7. mistwang

    mistwang LiteSpeed Staff

    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.

Share This Page