Since I host a lot of little webapps on my development workstation, and use SSL to protect passwords and other sensitive data, I have a lot of special proxy settings in my Apache config. I realized today, though, that I could replace most of them with the following single line:
RewriteRule /port(\d+)/(.*) http://localhost:$1/$2 [P,L]
Now, to access a Rails app running on port 3000, I can just request https://myhostname/port3000/, and the request will pass through the Apache proxy into the Mongrel backend. The same works for /port8080/, /port10080, etc., etc.




0 Responses to “mod_rewrite hack of the day”