In a .htaccess file, I have something like this to proxy Apache to Tomcat:

   RewriteRule (.*) http://localhost:8080/tomcat-app/$1 [P]

All the redirects as well as internal links in HTML files are going to the Tomcat app directly, rather than to Apache.

So I would use ProxyPassReverse and the like to translate correctly, but apparently I'm not allowed to use that directive in a .htaccess file. I don't really want to put them into the master Apache configuration because that means rebooting Apache every time there is a change. Which is why I like the RewriteRole [P]: unlike ProxyPass, it can be put into .htaccess.

What can I do to simulate ProxyPassReverse in a .htaccess file? Or more specifically, without requiring reboots on any change?


Use your main config file - you can do a graceful config reload by sending a USR1 signal to the process - your apache init script should have a reload command to do this.

/etc/init.d/apache2 reload
  • Well, according to blogs.oracle.com/oswald/entry/urban_legends_apache_reload_ed reload is basically the same as restart in terms of overhead. I was hoping to avoid either. Aug 26 '11 at 23:57
  • Ok, let's take a step back - what are you trying to avoid? Reload avoids downtime and dropped requests, which is its intent; whether it's the same processes or seamlessly inserted new ones is splitting hairs. I'm not sure why you'd be worried about "overhead" from re-reading config and spawning replacement processes - can you explain your concerns on this? Aug 27 '11 at 6:17
  • Think of a multi-user system where users can host web pages in ~/htdocs or such. They can update their sites at will for static HTML, PHP scripts etc. without requiring Apache restarts. I'd like to enable them to do the same thing for Tomcat apps mirrored into Apache's URL namespace via proxying. I'd have to give them sudo-style access to 'graceful', but even if I did that, Apache will not come back up if they screwed up their part of the Apache configuration: all the reasons why .htaccess files were invented in the first place, and why I'd like to use them if at all possible. Aug 29 '11 at 4:00
  • Reload and restart are different. The reload asks all the children to finish up current requests and close then starts new children with the new config the master process is not restarted so port 80 is kept open. Restart shuts the server down completely and starts it up again. The reload should get it up and serving new requests quicker but as apache should be able to fork new children with the new config before all the requests have finished.
    – Choffee
    Dec 13 '13 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.