gunicorn behind Apache web server

gunicorn is a python application server used to run python applications in production. This is normally run behind web servers like nginx or apache.

To configre gunicorn behind apache, enable following apache modules.

a2enmod proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html xml2enc

Restart apache web server

systemctl restart apache2

For web site running pythin application, add a virtual host like following.


    ServerName DOMAIN_NAME
    ServerAdmin [email protected]
    DocumentRoot "/home/flaskapp/myapp"

    ErrorLog ${APACHE_LOG_DIR}/flaskapp-error.log
    CustomLog ${APACHE_LOG_DIR}/flaskapp-access.log combined

    ProxyPass / http://127.0.0.1:5000/
    ProxyPassReverse / "http://127.0.0.1:5000/"

    
        Order allow,deny
        Allow from all
        Options Indexes FollowSymLinks MultiViews
        Satisfy Any
    


Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *