Dash, docker and nginx https

Dear all,

I have a dash app running on a docker container. I am running the container at port 8050 and I want to run it through https. I have already configured https and other containers (e.g., grafana) are working correctly, without issues.
For the dash app, let’s call it DASH, it is running well with HTTP. but when it comes to https (domain_name.com/DASH/, the login pop up is working perfectly, but the layout is stuck at loading, and for example with inspect function in the browser, https://domain_name.com/_dash-component-suites/dash/dash_table/bundle.v5_2_11m1719340598.js gives 404 not found. Any idea what to do to fix all that? or if I am missing some step?

Thank you for your help in advance

What is your nginx configuration?

Just the basic nginx conf block

server {
listen 80;
server_name SERVER_NAME;

# Redirect all HTTP requests to HTTPS
return 301 https://$host$request_uri;

}

server {
listen 443 ssl;
server_name tumwwft-precom-rest.srv.mwn.de;

ssl_certificate /PATH/TO/CERTIFICATE;
ssl_certificate_key /PATH/TO/KEY;

location /grafana/ {
proxy_pass http://localhost:3000/grafana/;
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 /dash/ {
    proxy_pass http://localhost:8050;
    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; 

}
}

Then I don’t know. It seems OK.

I am surprised that it works for http://domain_name.com/dash/ and not https://domain_name.com/dash/
In the URL https://domain_name.com/_dash-component-suites/dash/dash_table/bundle.v5_2_11m1719340598.js what’s certainly missing is the dash/ prefix . i.e. can you try if https://domain_name.com/dash/_dash-component-suites/dash/dash_table/bundle.v5_2_11m1719340598.js reachable ?

I mean , to me, it is not supposed to work either in HTTP. Using a sub domain seems more appropriate.

it works for http://domain_name.com:8050 not http://domain_name.com/dash/

Hello @malek,

Once hosted behind a route, did you make sure to adjust your app configuration when setting things up?

Adding the route declarations to the init, etc.

1 Like

From what I understood, if you access directly through http://domain_name.com:8050 you are bypassing nginx and directly accessing the Dash server that is listening on port 8050.

If you expect this server to be accessible at http://domain_name.com/dash/, I don’t think it will work (http or https), because I would not be surprised that dash always refer to the root path “/”.
For example, even if you access to http://domain_name.com/dash/ successfully, Dash will make an HTTP request like http://domain_name.com/_dash-layout to initialize your app, and similar other HTTP requests for every callbacks.

I am not sure if there is an option in Dash to specify that it should request /dash/_dash-layout instead of /_dash-layout
Maybe the route definition, as suggested @jinnyzor like url_base_pathname, requests_pathname_prefix , routes_pathname_prefix from API Reference | Dash for Python Documentation | Plotly

Side note : I think using a subdomain like dash.domain_name.com for this is just less trouble.

Subdomains require a new certificate, unless you have a wildcard certificate that can handle it.

@jinnyzor Indeed. I didn’t think about that. Thanks!