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.

I have 2 applications running on JBoss with an Apache server in-front.

The applications are currently being proxied by Apache:

ProxyPass /App1 http://mydomain.com:8080/App1
ProxyPassReverse /App1 http://mydomain.com:8080/App1
ProxyPass /App2 http://mydomain.com:8080/App1
ProxyPassReverse /App1 http://mydomain.com:8080/App1

I have 2 sub-domains:

 app1.mydomain.com
 app2.mydomain.com

So I can now access my apps with:

 http://app1.mydomain.com/App1
 http://app2.mydomain.com/App2

How can I configure Apache so that I can serve these apps from:

 http://app1.mydomain.com
 http://app1.mydomain.com

Is it possible to do this with a mod_rewrite rule?

Thanks!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The way to do this 'correctly' is to set up a couple of vhosts in your apache config like so:

NameVirtualHost *:80 #only if this is not present earlier in httpd.conf

<VirtualHost *:80>
    ServerName: app1.mydomain.com
    ProxyPass http://mydomain.com:8080/App1
    ProxyPassReverse http://mydomain.com:8080/App1
</VirtualHost>

<VirtualHost *:80>
    ServerName: app2.mydomain.com
    ProxyPass http://mydomain.com:8080/App2
    ProxyPassReverse http://mydomain.com:8080/App2
</VirtualHost>
share|improve this answer

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.