Project

General

Profile

[UserError] Restoring original IP address behind lighttpd reverse proxy

Added by alanlit almost 8 years ago

I am using lighttpd as a reverse proxy (using mod_proxy on Linux Mint) with certain urls getting sent off to a Java servlet (effectively) on another port of the same machine.

When I getRemoteAddress on the servlet request it (quite rightly) gives me 127.0.0.1, so I wish to configure ext_proxy to either not overwrite the request IP address or to stash it somewhere else (e.g. in X-Forwarded-For or some such header) where my Java WebApp can pick it up.

I've seen this question raised before, but the answers (basically use mod_extforward) seem to have misinterpreted the question since mod_extforward is all about getting the IP address from X-Forwarded-For header when a proxy is in use in front of lighttpd (e.g. so lighttpd access logs show the correct IP address).

I've dumped out the headers my Java servlet sees behind the lighttpd proxy and there is nothing containing the original IP address. Config for mod_proxy seems to offer no options ... so how do I get the original requester IP (or at least the upstream IP from my lighttpd instance) behind mod_proxy in lighttpd?

Tnx

Alan


Replies (3)

RE: Restoring original IP address behind lighttpd reverse proxy - Added by gstrauss almost 8 years ago

mod_proxy already adds X-Forwarded-For and X-Forwarded-Proto. What version of lighttpd are you using? Are you sure you're looking at all the request headers? Also, you might want to double-check lighttpd accesslog to make sure the request is going through lighttpd.

RE: Restoring original IP address behind lighttpd reverse proxy - Added by alanlit almost 8 years ago

I'm using 1.4.33. The requests are definitely going through the server and I believe I dumped all the headers .. I'll double check that.

RE: Restoring original IP address behind lighttpd reverse proxy - Added by gstrauss almost 8 years ago

According to commit history, every single version of lighttpd 1.4.x has mod_proxy providing X-Forwarded-For.

Is something between lighttpd reverse-proxy and your java applet stripping out that header?

    (1-3/3)