Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProxyPass and DocumentRoot on one domain

Tags:

Let's say I have the following configuration:

<VirtualHost domain.com>     # Server names, admins, logs etc...      ProxyVia On     ProxyRequests Off     <Location "/">         ProxyPass http://localhost:8080/tomcat-webapp/         ProxyPassReverse http://localhost:8080/tomcat-webapp/         Order allow,deny         Allow from all     </Location> </VirtualHost> 

Now, I want the address domain.com/forum to display content of my MyBB forum, which has its files inside the /var/www/forum directory. How to accomplish this?

like image 509
fracz Avatar asked Apr 25 '13 20:04

fracz


People also ask

What is ProxyPass and ProxyPassReverse?

The "ProxyPass" and "ProxyPassReverse" parameters are used to tell Apache how to proxy requests. They require the "mod_proxy.so" and "mod_proxy_http.so" Apache modules, which are loaded by default in RHEL5 and RHEL6, but check the following lines are uncommented in the "/etc/httpd/conf/httpd. conf" file to make sure.

What is the use of ProxyPass?

ProxyPass is the main proxy configuration directive. In this case, it specifies that everything under the root URL ( / ) should be mapped to the backend server at the given address.


2 Answers

Actually, I resolved this problem with the following code:

ProxyPass /forum ! ProxyPass / http://localhost:8080/tomcat-webapp/ ProxyPassReverse / http://localhost:8080/tomcat-webapp/ Alias /forum /var/www/forum 
like image 119
fracz Avatar answered Sep 30 '22 09:09

fracz


What it is recommending is using mod_rewrite to perform the ProxyPass instead of ProxyPass/ProxyPassReverse command.

Try something like:

RewriteRule  ^/forum   -  [L] RewriteRule  ^/(.*)    http://localhost:8080/tomcat-webapp/$1  [P,L] ProxyPassReverse /     http://localhost:8080/tomcat-webapp/ 
like image 38
Welsh Avatar answered Sep 30 '22 07:09

Welsh