Project

General

Profile

[Solved] Seamless reverse proxy

Added by kooper almost 10 years ago

Hi all

Sorry if this question has been asked a thousand times already. I'm trying to get my head around how Lighttpd works. What I'm interested in using it for is as a reverse proxy/ traffic manager of sorts, primarily to have multiple URLs using one public IP.

I'm just doing some testing to get to learn it, as well as confirm that I'd be able to do what I hope I can. As a trial, I've got a local VM running CentOS and Lighttpd, with me trying to get www.google.com served via Lighttpd.

My config in lighttpd.conf:

$HTTP["host"] == "google.test.corp" {
proxy.server = ( "" => ( ( "host" => "83.143.25.42", "port" => 80 ) ) )

modules.conf:

server.modules = (
"mod_access",
"mod_alias",
  1. "mod_auth",
  2. "mod_evasive",
  3. "mod_redirect",
  4. "mod_rewrite",
  5. "mod_setenv",
  6. "mod_usertrack",
    "mod_proxy",
    )

I've edited my local PC's hosts file to get "google.test.corp" from my lighttpd test server. What I'm seeing so far:

- Requests for google.test.corp reaches my lighttpd test server successfully
- My lighttpd test server is apparently unable to retrieve anything from Google itself (internet connectivity is working)
- 500 error returned to the user (in this case being me)

What I suspect is happening:

- Request for google.test.corp reaches lighttpd
- lighttpd connects to 83.143.25.42, but requests content for "google.test.corp" instead of "www.google.com"
- Google, in effect, tells lighttpd to take a hike
- lighttpd serves 500 error back to user

I think what needs to happen is that lighttpd needs to take the request for "google.test.corp", rewrite the URL as "www.google.com", get the content from Google, rewrite the URL back to google.test.corp, then serve the content back to the user. I'm just not sure how to do that though?

If I insert a rewrite rule, will this change the URL that the user sees to www.google.com, or will it keep appearing as google.test.corp?

I'm about to test the rewriting side of it now in any event, but thought I'd ask here in the meantime in case pointing me in the right direction is a quick and easy thing to do (for any kind souls out there willing to offer quick advice I mean... might not be so quick and easy for me to grasp it :P ).

Thanks in advance for any help.


Replies (3)

RE: Seamless reverse proxy - Added by kooper almost 10 years ago

Just to add the essential info:

[root@localhost lighttpd]# /usr/sbin/lighttpd -v
lighttpd/1.4.35 (ssl) - a light and fast webserver
Build-Date: Mar 12 2014 17:19:32

[root@localhost lighttpd]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)

RE: Seamless reverse proxy - Added by l2f almost 10 years ago

I did a reverse proxy to connect to shellinabox

lighttpd.conf:

proxy.server = ( 
    "/shell" => 
    ( ( 
        "host" => "127.0.0.1",
        "port" => 4200
    ) )
)

modules.conf

##
## mod_proxy
##
include "conf.d/proxy.conf" 

It works, I run FreeBSD 9.3-p13 and lighttpd 1.4.35

l2f

RE: [Solved] Seamless reverse proxy - Added by gstrauss about 8 years ago

lighttpd mod_proxy is a "reverse proxy", not a forward proxy. Proxies like squid or varnish might be better suited for what you are trying to do.

    (1-3/3)