1

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.

3

This is actually what I was looking for.

<VirtualHost *:80>
ServerName subdomain.yourdomain.com
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
</VirtualHost>
1

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> 

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.