0

I have an Ubuntu Server 14.04 with Apache 2.4.7 and Wildfly 8 installed. Apache runs in the front and Wildfly in the back. Apache proxies all the apps running on Wildfly.

Now I am trying to proxypass one of my apps from Wildfly with the domain mysubdomain.example.com, but I have unwanted side effects. It adds itself to the main domain example.com/mysubdomain as well, which is not what I want. First I added this configuration to /etc/apache2/sites-available/000-default.conf:

<VirtualHost *:80>
    ServerName mysubdomain.example.com
    ServerAlias www.mysubdomain.example.com
    ProxyPass / http://localhost:8080/myapp/
    ProxyPassReverse / http://localhost:8080/myapp/
</VirtualHost>

Then I added the same for SSH in /etc/apache2/sites-available/ssl.conf:

<VirtualHost *:443>
    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/mysubdomain.mydomain.crt
    SSLCertificateKeyFile /etc/ssl/private/mysubdomain.mydomain.key

    ServerName mysubdomain.example.com
    ServerAlias www.mysubdomain.example.com

    ProxyPass / http://localhost:8080/myapp/
    ProxyPassReverse / http://localhost:8080/myapp/
</VirtualHost>

This configuration does not work like this. I was forced to add another configuration in order to make this work. I had to add into /etc/apache2/apache2.conf:

<Location "/myapp/">
    ProxyPass "http://localhost:8080/myapp/"
    ProxyPassReverse "http://localhost:8080/myapp/"
</Location>
<Location "/myapp">
    ProxyPass "http://localhost:8080/myapp"
    ProxyPassReverse "http://localhost:8080/myapp"
</Location>

This works (the good thing):

http://mysubdomain.example.com
https://mysubdomain.example.com

This comes with it (the bad thing):

http://example.com/mysubdomain

What must I do to only affect the subdomain without adding anything to the main domain?

  • You need to add conditions on the other vhosts to load only the app wanted. – Florin Asăvoaie Nov 30 '15 at 0:15
  • Hi @FlorinAsavoaie How would I do that? – Socrates Nov 30 '15 at 0:37
  • Deny the requests on the other VirtualHosts using mod_rewrite. – Florin Asăvoaie Nov 30 '15 at 1:31
  • @FlorinAsavoaie Sorry, just noticed big stackoverflow-formatting issues. Quickly repaired them. – Socrates Nov 30 '15 at 5:08
  • @FlorinAsavoaie Ok, mod_rewrite to deny requests on example.com/mysubdomain, but allow them on mysubdomain.example.com? Actually, I am happy with the <VirtualHost ... />-settings. I just want to get rid of example.com/mysubdomain, but keep the rest. How would I do that? – Socrates Nov 30 '15 at 5:11

Your Answer

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

Browse other questions tagged or ask your own question.