23

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?

Stefanos Kargas
  • 10,547
  • 22
  • 76
  • 101
fracz
  • 20,536
  • 18
  • 103
  • 149

3 Answers3

40

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
fracz
  • 20,536
  • 18
  • 103
  • 149
  • Any idea about this question? Thanks! http://stackoverflow.com/questions/31271434/apache-mod-proxy-with-tomcat-and-svn – Amir Jamak Jul 08 '15 at 06:45
  • @fracz can you post whole .conf file here ? – shyammakwana.me Jul 23 '20 at 06:43
  • Sort of works, but it seems like the permissions are wrong vs using `Directory`? – wogsland Oct 19 '20 at 14:19
  • 1
    It worked! Thanks. Also, for someone noob like me, just replace the whole .. tag with this -- basically don't add it inside the tag, replace the whole tag with this text . Took a while to realise – Nertan Lucian Aug 19 '22 at 15:03
  • it would nice if you put your whole configuration. I'm new to this thing and not really sure where to put things – Ago Mar 03 '23 at 15:51
3

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/
Welsh
  • 5,138
  • 3
  • 29
  • 43
0

I use:

<VirtualHost *:80>
#other irrelevant configs here
ProxyPass /forum http://localhost:8080/myBB
ProxyPassReverse /forum http://localhost:8080/myBB
ProxyPass / http://localhost:8081/tomcat-app
ProxyPassReverse / http://localhost:8081/tomcat-app
</VirtualHost>

You don't have to say "tomcat-app" if your tomcat app is the root app.

Calicoder
  • 1,322
  • 1
  • 19
  • 37