Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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
share|improve this answer
    
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. –  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 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. –  Johannes Ernst 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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