Have the pleasure to answer my own question (hope it will help others)
AI (chatGPT) helped me to find a solution for running different py4web applications on the same server and py4web instance and nginx
( maybe it should be added to the deployment documentation)
As far as I understand the problem comes from the fact that nginx routing is based on the path but py4web is based on the app name
Fortunately nginx can translat between the two ( i am definitely knows very litle about nginx and py4web but wished that it was explained better in the docs)
So here is an enginx server block specific to a py4web application and specific url, in this case the url is
example1.com and the app name is example1
( I also added the _dashboard app but any other app will not be available unless specific server block is added or a generic one like server_name $hostname;)
A server block for the exampl1 application
server {
listen 443 default_server ssl;
#server_name $hostname;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
keepalive_timeout 70;
# Dashboard
location /_dashboard/ {
allow 127.0.0.1;
allow my.ip.addr.at_work;
deny all;
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;
proxy_pass
http://127.0.0.1:8000/_dashboard/;
}
location = / {
return 302 /example1/;
}
location /example1/ {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $http_host;