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.
1 |
a2enmod proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html xml2enc |
Restart apache web server
1 |
systemctl restart apache2 |
For web site running pythin application, add a virtual host like following.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<VirtualHost *:80> ServerName DOMAIN_NAME ServerAdmin admin@serverok.in 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/" <Directory "/home/flaskapp/myapp/static/"> Order allow,deny Allow from all Options Indexes FollowSymLinks MultiViews Satisfy Any </Directory> </VirtualHost> |