Location
Typical Gunicorn template files
- gunicorn.tpl – HTTP (port 80)
- gunicorn.stpl – HTTPS (port 443)
- gunicorn.sh – optional script
- /usr/local/hestia/data/templates/web/nginx/gunicorn.tpl
- /usr/local/hestia/data/templates/web/nginx/gunicorn.stpl
- (and gunicorn.sh if it exists)
ls -la /usr/local/hestia/data/templates/web/nginx/
If template not exist:
sudo nano /usr/local/hestia/data/templates/web/nginx/gunicorn.tpl
#=========================================================================#
# Default Web Domain Template #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
# https://hestiacp.com/docs/server-administration/web-templates.html #
#=========================================================================#
server {
listen %ip%:%proxy_port%;
server_name %domain_idn% %alias_idn%;
error_log /var/log/apache2/domains/%domain%.error.log error;
location / {
# Replace the default proxy_pass with Gunicorn socket:
proxy_pass http://unix:/home/%user%/web/%domain%/public_html/gunicorn.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /static/ {
alias /home/%user%/web/%domain%/public_html/static/;
expires max;
}
location /media/ {
alias /home/%user%/web/%domain%/public_html/media/;
expires max;
}
# etc...
include %home%/%user%/conf/web/%domain%/nginx.conf_*;
}
sudo nano /usr/local/hestia/data/templates/web/nginx/gunicorn.stpl
#=========================================================================#
# Default Web Domain Template #
# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST WHEN REBUILDING DOMAINS #
# https://hestiacp.com/docs/server-administration/web-templates.html #
#=========================================================================#
server {
listen %ip%:%proxy_ssl_port% ssl;
server_name %domain_idn% %alias_idn%;
ssl_certificate /home/%user%/conf/web/%domain%/ssl/%domain%.pem;
ssl_certificate_key /home/%user%/conf/web/%domain%/ssl/%domain%.key;
location / {
proxy_pass http://unix:/home/%user%/web/%domain%/public_html/gunicorn.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /static/ {
alias /home/%user%/web/%domain%/public_html/static/;
expires max;
}
location /media/ {
alias /home/%user%/web/%domain%/public_html/media/;
expires max;
}
include %home%/%user%/conf/web/%domain%/nginx.ssl.conf_*;
}
sudo chmod 644 /usr/local/hestia/data/templates/web/nginx/gunicorn.tpl
sudo chmod 644 /usr/local/hestia/data/templates/web/nginx/gunicorn.stpl
Copying to the new HestiaCP server
- Copy the same .tpl, .stpl (and optional .sh) files into /usr/local/hestia/data/templates/web/nginx/ on the new server.
- In HestiaCP, edit the domain and choose this template as the “Nginx template” (or “Proxy template”) for the domain.
- Rebuild the domain so the config is regenerated, e.g.:
- Rebuild user: v-rebuild-user username
-
sudo /usr/local/hestia/bin/v-rebuild-user admin
- Rebuild one domain: v-rebuild-web-domain username domain.tld