âWhen you place multiple sites in a single bench changes can affect all sites at once, so you definitely want to keep staging and production in distinct benchesâ - Do you mean upgrades and updates only?
To be 100% honest, I do not yet know, I am researching this my self right now.
Donât you have a guide on how I can implement your suggestion? - I am new to Frappe and to LinuxâŚ
No. I have had to pick over bits and pieces of instructions and examples here in the forum and on the many 3rd party installation guides. Even with a lot experience already it has been difficult. A single small mistake can go unnoticed, then cause inexplicable failures later.
However if you have a successful installation already, you just need to start again from where you created your first bench. Create a second bench and proceed as before.
Also, will these benches be able to point to independent domain names and thus operate independent of each other?
When setting up NGinx configuration you need to be aware of directory names and config unique names. This is a template I use to generate my NGinx config files:
upstream frappe-bench-${NICK}-frappe {
server 127.0.0.1:${BENCH_PORT} fail_timeout=0;
}
upstream frappe-bench-${NICK}-socketio-server {
server 127.0.0.1:${SCKTIO_PORT} fail_timeout=0;
}
server {
listen 443 ssl;
server_name ${VHOST};
ssl_certificate /etc/letsencrypt/live/${VHOST}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/${VHOST}/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/dhparams_4096.pem;
root /home/erpdev/frappe-bench-${NICK}/sites;
add_header X-Frame-Options "SAMEORIGIN";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
location /assets {
try_files \$uri =404;
}
location ~ ^/protected/(.*) {
internal;
try_files /\$host/\$1 =404;
}
location /socket.io {
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Frappe-Site-Name \$host;
proxy_set_header Origin \$scheme://\$http_host;
proxy_set_header Host \$host;
proxy_pass http://frappe-bench-${NICK}-socketio-server;
}
location / {
rewrite ^(.+)/\$ \$1 permanent;
rewrite ^(.+)/index\.html\$ \$1 permanent;
rewrite ^(.+)\.html\$ \$1 permanent;
location ~ ^/files/.*.(htm|html|svg|xml) {
add_header Content-disposition "attachment";
try_files /\$host/public/\$uri @webserver;
}
try_files /\$host/public/\$uri @webserver;
}
location @webserver {
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Frappe-Site-Name \$host;
proxy_set_header Host \$host;
proxy_set_header X-Use-X-Accel-Redirect True;
proxy_read_timeout 120;
proxy_redirect off;
proxy_pass http://frappe-bench-${NICK}-frappe;
}
# error pages
error_page 502 /502.html;
location /502.html {
root /usr/local/lib/python3.8/dist-packages/bench/config/templates;
internal;
}
# optimizations
sendfile on;
keepalive_timeout 15;
client_max_body_size 50m;
client_body_buffer_size 16K;
client_header_buffer_size 1k;
# enable gzip compresion
# based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/font-woff
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component
;
# text/html is always compressed by HttpGzipModule
}
You will find the following variables: NICK, BENCH_PORT, SCKTIO_PORT, VHOST.
Site PRD:
- NICK = PRD
- BENCH_PORT = 8000
- SCKTIO_PORT = 9000
- VHOST = prd.erpnext.host
Site PRD:
- NICK = STG
- BENCH_PORT = 8001
- SCKTIO_PORT = 9001
- VHOST = stg.erpnext.host
Look for âupstreamâ and âproxy_passâ. Proxy pass basically tell NGinx, âNo static files to return from here. Go ask Mr. & Mrs Upstream if they have anythingâ. The upstream names have to be unique across all your sites.
Look for ârootâ. That tells NGinx, âHey! Here are the static files you wanted.â Likewise the NICKname in there ensures the two sites deliver their own static files, not anyone elseâs.