I have two docker containers running Tornado applications, named app1
and app2
on a Ubuntu VM. The VM has a domain name ubuntu.somesite.com
. I can access one of them with docker port forwarding at ubuntu.somesite.com:8080
. Instead I want both apps to be accessible at ubuntu.somesite.com/app1
and ubuntu.somesite.com/app2
. What would be the best way to accomplish this? I tried using apache virtual hosts but didn't get very far.
You need to expose both docker containers on the host network, of course on two different ports (let's say 8080 and 8081).
Than you need a reverse proxy in your host. Apache 2.4 is one possible choice. You could use a virtualhost like this:
<VirtualHost *:80>
ServerName ubuntu.somesite.com
<Location />
Order allow,deny
Allow from all
Require all granted
</Location>
ProxyPass /app1 http://127.0.0.1:8080/
ProxyPassReverse /app1 http://127.0.0.1:8080/
ProxyPass /app2/ http://127.0.0.1:8081/
ProxyPassReverse /app2/ http://127.0.0.1:8081/
</VirtualHost>
Please note that this config will not work with apache 2.2 or older.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With