Deploy streamlit with reverse proxy nginx mutliples ports

Hello Community,

I’m new in this forum and I’m deploying streamlit with apps in Linux server with nginx reverse proxy.
I explain my situation :

I have two environnment, production and test
In each environnment I have 2 applications which use differents ports :

TEST :
app.service1 = 8501 β†’ app name single
app.service2 = 8502 β†’ app name mosaic

PROD :
app.service4 = 8505 β†’ app name single
app.service5 = 8506 β†’ app name mosaic

I want to deploy my streamlit in my server with nginx reverse proxy, I have so two address :
(Use for example)
test.environnment.com
prod.environnment.com

Here my nginx config file for prod.environnment.com :

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name prod.environnment.com;
ssl_certificate /etc/letsencrypt/live/prod.environnment.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/liveprod.environnment.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

root /home/my-user/streamlit/;
index  index.html;

proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;

location  /single {
    proxy_pass  http://127.0.0.1:8505;
    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_buffering    off;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;

}

location /mosaic {
    proxy_pass  http://127.0.0.1:8506;
    rewrite ^/mosaic(.*) /$1 break;
    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_buffering    off;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;

  }

}

When I access to my webpage prod.environnment.com/single I have a white page
But when I access to prod.environnment.com/single/single I have a white page with β€œPlease wait…”

Can you help to solve errors in my nginx file,

Thanks you for your help :pray:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.