3

I currently have a server which runs a Python web app on port 8000. It's publicly accessible on the web (at the server's IP) with no issues.

I'd like to make this web app available on a subdomain so that you don't have to access the IP address in order to run the web app. I've already managed to open up a subdomain that mirrors what's on the root directory, but how can I route my Python web app through that subdomain using Apache?

Thanks for any help.

javathunderman
  • 221
  • 2
  • 11

2 Answers2

3

This is actually what I was looking for.

<VirtualHost *:80>
ServerName subdomain.yourdomain.com
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
</VirtualHost>
javathunderman
  • 221
  • 2
  • 11
2

If your DNS is configured correctly and your subdomain my-app.example.com points to the ip-address of your server people can immediately use http://my-app.example.com:8000/ instead of http://<your ip-address>:8000.

If you already have any existing websites on the default port for http (TCP port 80) you can't make you web app listen on port 80 directly. Instead you can use Apache's Reverse Proxy functionality so that people won't need to enter the port number :8000 and can access your App from the default HTTP port by using http://my-app.example.com/

Set up a new virtual host for my-app.example.com :

<VirtualHost *:80>
   ServerName my-app.example.com
   ProxyPass / http://127.0.0.1:8000/
   ProxyPassReverse / http://127.0.0.1:8000/
</VirtualHost> 
HBruijn
  • 77,029
  • 24
  • 135
  • 201