-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support serving the dashboard from a non-root path (ngnix proxy) #24
Comments
Incidentally, the web app logs show a consistent 308 redirection
So from the logs above, the web app must be getting the https://openpath-stage.nrel.gov/admin requests and redirecting them to http. We need to figure out why. |
It could be that the redirect is from AWS cognito, but we do need to support cognito, so I decided to revert the previous changes, start investigating from scratch and fix properly. |
Ok, so here's what's happening As I expected, we are trying to retrieve the assets (e.g. dash_core_components.v2_9_0m1681396826.js) but because of the way that dash is set up, we are doing so from https://openpath-stage.nrel.gov/_dash-component-suites/dash/dcc/dash_core_components.v2_9_0m1681396826.js which is why none of the assets are found and the loading fails we don't need to (and shouldn't need to) serve the whole app at It seems like this should be handled by either |
Per plotly/dash#489 we can do
and if we add the assets path But this is an open source project; let's verify from the source code |
Bingo (I think)! Note that the dash documentation says that
So this is a supported use case and should work as long as we get configure everything correctly. Looking at the dash configuration
the This indicates that the config here
we should just need
|
Bingo! I don't even think that we need to change any code to do this; we just need to set the Yup! we initialize it from
and
|
One of the errors is
|
ok so the paths error is from
In the backtrace, I don't see any of our code everything is from |
The related stripping happens here
Ok so that's pretty straightforward instead of https://openpath-stage.nrel.gov/admin/data as reported by @ssharma before We just need to use the relative URLs |
Fortunately, there are not a lot of
|
The 500 error is at
Related code is here and is a fairly simple query/projection. This is a documentDB issue so tracking it in a separate issue. |
reverted @swastis10's earlier changes using force-push |
To fix this, we first need to be able to reproduce it, and then we need to show that we have fixed it. |
So that we can test the reverse proxy configuration fixes in dev This fixes #24 (comment) The `docker-compose` (except for `nginx`) should be kept consistent with the production `docker-compose-prod.yml` with the exception of `DASH_DEBUG_MODE`, which is set to true so that we can debug errors in the setup more easily Testing done: - Built and ran the docker-compose - Accessing http://localhost:8060/admin gives the same error as #24 (comment) ``` Uncaught ReferenceError: DashRenderer is not defined <anonymous> http://localhost:8060/admin/:58 ```
This internally sets the `requests_pathname_prefix`, which allows us to load all the assets (including the javascript files) correctly. This is a partial fix for #24 that implements the first step in #24 (comment)
This fixes #24 (comment) #24 (comment) #24 (comment) Since there are not a lot of hrefs and they are all in the same file #24 (comment) ``` $ grep -r href . | grep -v .git ./utils/cognito_utils.py: dbc.Button('Login with AWS Cognito', id='login-button', href=CognitoConfig.AUTH_URL, style={ ./app_sidebar_collapsible.py: href=dash.get_relative_path("/"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/data"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/tokens"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/map"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/push_notification"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/settings"), ```
This fixes #24 (comment) #24 (comment) #24 (comment) Since there are not a lot of hrefs and they are all in the same file #24 (comment) ``` $ grep -r href . | grep -v .git ./utils/cognito_utils.py: dbc.Button('Login with AWS Cognito', id='login-button', href=CognitoConfig.AUTH_URL, style={ ./app_sidebar_collapsible.py: href=dash.get_relative_path("/"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/data"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/tokens"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/map"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/push_notification"), ./app_sidebar_collapsible.py: href=dash.get_relative_path("/settings"), ``` Testing done: - we can click on all tabs of the dashboard, and there are no errors
While serving the dashboard from a non-root path - e.g. using an ngnix reverse proxy, we need to special configuration. Otherwise, dash tries to load the assets from the root URL, which fails.
We use an ngnix reverse proxy in the NREL hosted environment, where the app is hosted at
https://[deployment]-openpath.nrel.gov/admin
The application was working fine when we are testing on localhost because the app is served from the root URL but when we deploy, the app is served from the /admin URL.
The error we get is:
In order to fix it, we have used url_base_pathname
This launches the app at
http://0.0.0.0:8050/admin/
instead ofhttp://0.0.0.0:8050/
However, this continued to fail on deployment with the error
"The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again." aka 404
it seems like it is getting routed correctly to the dash app since https://openpath-stage.nrel.gov/admin1/ gives a different 404 and is redirected to https://www.nrel.gov/notfound
https://openpath-stage.nrel.gov/admin/ was still giving us a different 404, so presumably from within the dash app
On further investigation, this was because the app was published at http://0.0.0.0:8050/admin/, but the reverse proxy was still redirecting to proxy_pass http://[continername]:8050/;
So we ended up with
INFO:dash.dash:Dash is running on http://0.0.0.0:8050/admin/
INFO:werkzeug:192.168.1.73 - - [13/Apr/2023 02:30:46] "�[33mGET / HTTP/1.1�[0m" 404 -
Anyway, so I attempted to fix this by changing ngnix so that it would redirect to
proxy_pass http://[containername]:8050/admin;
We are now getting an infinite redirect between http and https
The text was updated successfully, but these errors were encountered: