1

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?

Johannes Ernst
  • 1,037
  • 4
  • 16
  • 26

1 Answers1

3

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
Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Well, according to http://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. – Johannes Ernst 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? – Shane Madden Aug 27 '11 at 06: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. – Johannes Ernst Aug 29 '11 at 04: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