Serve a dash app from multiple URLs

Hey, I have a dash app that normally runs on its own and its called from a https://example.com with no problems.

The way its served its through nginx and its configuration file looks like this:

location / {
proxy_pass http://localhost:8080;
}

However, i want to call the same app hosted in that site but through a different url, i need it to work in both sites, for example, when accessing this url: https://example2.com/dashapp-demo/ this second page is also served with nginx and its conf file looks like this:

location /dashapp-demo {
proxy_pass http://localhost:8080;
proxy_set_header Host /;
}

I have seen similar posts with the use of url_base_pathname and requests_pathname_prefix but modyifing those would crash https://example.com. The error i get on is https://example2.com/dashapp-demo/ “Uncaught ReferenceError: DashRenderer is not defined”. This as i understand it is that dash is not able to find the location of the files for the app. Is there a way to pass header to the requests such as proxy_set_header X-Base-Path /godash/;

I don’t want the modification of base url because this would mean i would have to run two apps for the same purpose, and i am sure there should be a way to pass the correct header request to the original app.

Is there a way to set multiple url_base_pathname or requests_pathname_prefix ? Is there a request header specific so i can change it?

Thank you very much!

Hello @alejohenao,

This is a very tricky setup.

Why exactly do you need this? Can you not use something like an iframe for whichever site you are hosting it in?

1 Like

I don’t exactly need it. I want to serve it this way to avoid the problem of having the same app running two times. This would mean that one change on app1 would have to happen also on app2, manually. App1 is for external use, and some clients use it regularly. App2 is for internal use, so very few people have access, however, people that access App2 cannot see the url of App1, this is why i’m masking it with proxy_pass. This is due to confidential problems.

Now for the second question, you mean an iframe containing the dash app? That is a nice suggestion. I will try it and bring back the results.

1 Like

Hey @jinnyzor i solved with a responsive iframe. There is just one problem, users may still see the URL when inspecting the page. But, this solves the issue for now while i research a more advanced nginx solution.

Thank you!

@alejohenao,

You’re welcome.

Having security by only not having people see the website url is not exactly the greatest safeguard.

I’d recommend looking at some sort of authentication and permission based interaction to keep your site secure.

@jinnyzor Hey, so i still have one thing to solve.

That is that when accesing the dash app from the direct link, a basic auth (from dash_auth) pop ups and asks for login. But when accessing it through the iframe, it does not ask for login and only results in Login Required message. I’ve tried passing a cookie wiht proxy_set_header with no luck. Do you have any experience on this?

Hmm, not with basic auth.

I have used flask-login however, which uses cookies.