Need a lightTPD guru!
February 16, 2006 12:27 PM   Subscribe

Moving from Apache to lightTPD and I'm having trouble with RewriteCond and RewriteRule.

I've got the following RewriteCond and RewriteRule lines in Apache on a working Rails application. I've successfully moved the app over to LightTPD except for these rewrites for a specific part of the application.

I'm not terribly good with Apache's use of these either, so I'm hoping someone will take pity on me and help get this done. I've tried getting help on it from the #lighttpd IRC channel without success, because no one I've talked to seems to know how this would be done.

Help me, MeFI Wan, you're my only hope!
RewriteEngine On
# put authorization details in our header
RewriteCond %{REQUEST_URI} ^/blah-api/
RewriteRule /(.*) - [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# put request REST path into another header
RewriteCond %{REQUEST_URI} ^/blah-api/
RewriteCond %{REQUEST_URI} !^/blah-api/api-dispatch.cgi
RewriteRule /jobtips-api/(.*)$ /blah-api/api-dispatch.cgi [E=X-BLAH_RESOURCE:$1,PT]
In the event someone solves this completely with their response, I will donate $10 to their favourite charity. I really need this to work.
posted by Kickstart70 to Computers & Internet (1 answer total)
 
I haven't used lighttpd, but this seemed interesting. I read through the source of lighttpd's mod_rewrite module and there's nothing there that uses environment variables, so if it's possible to do what you want at all in lighttpd, it's not done with mod_rewrite.

If it's your own app, I'd recommend porting the app to lighttpd, not the Apache rewrite rules.

It's a bit hackish that that uses mod_rewrite in Apache the first place; you're not rewriting URLs, after all, you're filling the environment based on their content. But the reason for that hack is that Apache prevents you from accessing HTTP auth info in the environment in the first place.

This code snippet looks as though lighttpd simply doesn't require the workaround; you should be able to use the HTTP_AUTHENTICATION environment variable without having to populate it yourself. (Note that there's no "X_" there.)

Your second recipe ought to be easy; the full request path should be in REQUEST_URI in the environment to begin with, and you can trim out the constant in your app instead of having mod_rewrite do it. Based on that other snippet (I don't know much ruby, and even less rails, and still less lighttpd), something like
@request.env["REQUEST_URI"].scan(/^\/jobtips-api\/(.*)$/i).to_s
One thing you might find handy is to write a little app that just goes through each element of @request.env and prints out its name and value; that way you can find out empirically if what you need is in the environment.
posted by mendel at 7:25 PM on February 16, 2006


« Older Have Cat... Will generate electricity for food...   |   Where can I find a good CD head unit for my new... Newer »
This thread is closed to new comments.