Search code examples
wordpressdockerflaskdeploymentsubdomain

How to deploy dockerised Flask web app on a subdomain


I have a dockerised flask app and want to deploy it on a custom domain.

What I would like would be to create a Wordpress for the main website (presentation blog and everything to make it simpler) on mydomain.com and deploy my flask app on app.mydomain.com

First of all is it a good idea ? And if so what is the best way to connect both in a good way ?

Thanks in advance !


Solution

  • You can solve the problem using a reverse proxy such as nginx. By using nginx you will be able to redirect the request to the correct application depending on the domain it comes from.

    pseudo nginx configuration:

     server {
            #your other config....
    
            #redirect all request from your.domain.com to your wordpress app.
            if ($host = your.domain.com) {
                #redirect traffic to wordpress upstream
            }
    
           #redirect all unsecure www to secure www
            if ($host = your.sub.domain.com) {
                #redirect traffic to flask upstream
            }
        }