lighty's life

lighty developer blog

X-Sendfile's New Friend: X-Rewrite-*

Today on IRC I got a question on:
Fobax can you x-send-file from fast-cgi to a proxy request?
Or asked in another way ?
Can you use a mod_proxy_core backend to rewrite a URL or a Host header ?
After 30 minutes of coding … Yes, you can … Some tweaking and here and there and we had:
proxy-core.allow-x-rewrite = "enable"
which allows you to send:
HTTP/1.0 200 OK
X-Rewrite-URI: /pi.php
X-Rewrite-Host: www.foobar.com
as response and lighty will replace both values and the original request and start the whole request from scratch. Here I rewrite the incoming request to use another internal Host and a new URI.

What is this good for ?

* rewriting http://user.example.org/ to http://xample.org/~user/ * denying access to host with unwanted content based on the Hostname * filtering in general Do you have other examples ?

Enable javascript to load comments.

Please note that we won't accept comments for posts older than 3 months! Also please use our bug tracker to report bugs, and our irc channel #lighttpd@freenode to chat.

« mod_proxy_core got X-Sendfile Support PRE-RELEASE: lighttpd-1.4.12-20060724-0947.tar.gz »