-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
DASH_PROXY #1289
DASH_PROXY #1289
Conversation
and verify the proxy will see your app!
4a61cda
to
7814009
Compare
@@ -1332,7 +1331,8 @@ def enable_dev_tools( | |||
|
|||
if dev_tools.silence_routes_logging: | |||
logging.getLogger("werkzeug").setLevel(logging.ERROR) | |||
self.logger.setLevel(logging.INFO) | |||
|
|||
self.logger.setLevel(logging.INFO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't do all that much with self.logger
but what we do we always want the user to see - not just when silencing built-in route logging.
|
||
def verify_url_part(served_part, url_part, part_name): | ||
if served_part != url_part: | ||
raise ProxyError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we happy with proxy errors throwing, or would it be better to just show a warning but keep going?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this: If we throw an error when the served_url
portion of DASH_PROXY
does not match what's already available in protocol/host/port either through defaults or env variables, why force the user to provide it in the first place? Why not just reuse what we already have and use DASH_PROXY
only for the proxied url part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DASH_PROXY
presumably comes from some system configuration at a level that's inaccessible to Dash itself, it's just being reported by the environment as something Dash needs to obey.
But I guess that brings up the option to do the reverse of what you're suggesting: ignore host
and port
when we have a DASH_PROXY
- maybe throw a warning or an error if the user tries to override those and they conflict with the proxy, otherwise just run with the values indicated by the proxy.
I don't think we can do that with the protocol, because if you're using https you also need to provide the cert and key. But I get the impression (@gzork can you confirm this?) that at least in our own use of such proxies, encryption is handled by the proxy itself so DASH_PROXY
will look like http://<local>::https://<public>
. So if the user did provide ssl_context
when the proxy indicates http
it would be an error but that's unlikely to happen accidentally. And the reverse won't happen if the proxy is handling encryption and this is correctly reflected in DASH_PROXY
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least in our own use of such proxies, encryption is handled by the proxy itself so DASH_PROXY will look like http://::https://.
That's correct, in our case the encryption is handled by haproxy
on the Dash Enterprise server, and I think it's safe to generally also assume that it will be handled by the proxy itself, a note either in the docs or elsewhere would still be good though.
|
||
self.logger.info("Debugger PIN: %s", debugger_pin) | ||
if not os.environ.get("FLASK_ENV"): | ||
os.environ["FLASK_ENV"] = "development" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complete message you get now (ours plus the built-in Flask message) looks like:
$ python app1.py
Dash is running on http://127.0.0.1:8050/
Warning: This is a development server. Do not use app.run_server
in production, use a production WSGI server like gunicorn instead.
* Serving Flask app "app1" (lazy loading)
* Environment: development
* Debug mode: on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question/comment about DASH_PROXY
relationship with other env variables but don't have a strong opinion of my own on how this integrates with other systems. Otherwise seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me.
I haven't thought about this earlier, but I now wonder if it's worth having both the served url and proxied url; having the served url allows to verify of that corresponds to the parameters (protocol
, host
and port
), but if DASH_PROXY
(or it could be under a different name in that case) had only the proxied_url
then we'd just print that.
I guess this would lead us to the question; Aside from printing the right url for the app, do we care about validating the served url/parameters ?
Unfortunately I think we do need all the information scattered between the separate vars I suppose an alternative to throwing an error when the local settings don't match the proxy would be to just ignore the local settings and use the proxy. That wouldn't change the variables at all, just how and when they're used. That feels a bit too magical to me but I could be convinced. |
app.run_server
looks for a new env varDASH_PROXY
and uses this to:DASH_PROXY
should look like{input}::{output}
, eg:http://0.0.0.0:8050::https://my.domain.com
CHANGELOG.md