Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have two Python applications hosted on one server. One being an API and the other being a UI. Both have two different domains: domain-api.com for the API and domain.com for the UI. I have multiple instances of each application, and instances are behind a load balancer accessible through those domains. They are running on Apache.

I have two virtual hosts for each application. The UI's virtual host:

<VirtualHost *:443>
  ServerName https://domain.com
  ProxyPass /api/ https://domain-api.com

And the API:

<VirtualHost *:443>
  ServerName https://domain-api.com

This allows me to reach the API using either domain-api.com or domain.com/api. The problem here is that to reach an instance, it needs to be reached using that domain (i.e: put on the load balancer). Sometimes, I want to access an instance directly through it's hostname.

For example, say I have a hostname with the name of 01.thisapp.somedomain.com. I tried adding that as a ServerAlias but that did not work. Essentially, I want to be able to reach the UI using 01.thisapp.somedomain.com, and the API using 01.thisapp.somedomain.com/api/. It seems that the ServerAlias and ServerName do not take paths.

I also added 01.thisapp.somedomain.com as a ServerAlias for both, and added ServerPath /api/ in the API's virtual host but that did not work either.

The reason the original domain set up works is both they end up having two different domains, which works easily with ServerName. It does not handle paths as well, however.

What's the best way to match aliases (or second ServerNames) by specifying the path in the virtual host files so that I can access a specific instance using the hostname as described above?

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.