superset icon indicating copy to clipboard operation
superset copied to clipboard

/shortner API does not take into account when Superset is behind a reverse proxy to be served over HTTPS

Open PeterCahn opened this issue 6 years ago • 3 comments

When Superset is served over HTTPS by a reverse proxy (nginx/Apache), the generated URL has "http" as scheme instead of "https". The URL scheme is generated from the value of request.scheme, but it should take into account also headers like X-Forwarded-Proto and, in general, X-Forwarded-* headers (e.g for host).

https://github.com/apache/incubator-superset/blob/20e68c87402414fabb3e0fd715be487fa7ebf5cc/superset/views/core.py#L670

Expected results

The URL starts with "https://"

Actual results

The URL starts with "http://"

Screenshots

How to reproduce the bug

  1. Put nginx or Apache in front of Superset to serve it over HTTPS (Superset has config "ENABLE_PROXY_FIX = True" and the server adds the header X-Forwarded-Proto and sets it to "https")
  2. Go to a dashboard
  3. Click on the arrow on the right, then click to "Share dashboard"
  4. See error

Environment

  • superset version: 0.34.0
  • python version: 3.6.9

Checklist

  • [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [ ] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

HTTPS works as expected on all others urls without problems, the reverse proxy redirects all the requests from http to https.

PeterCahn avatar Dec 16 '19 10:12 PeterCahn

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.83. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

issue-label-bot[bot] avatar Dec 16 '19 10:12 issue-label-bot[bot]

Strange, this should work correctly since we are setting: PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1, "x_prefix": 1}

And then:

            from werkzeug.middleware.proxy_fix import ProxyFix

            self.flask_app.wsgi_app = ProxyFix(
                self.flask_app.wsgi_app, **self.config["PROXY_FIX_CONFIG"]
            )

Are you sure your X-Forwarded-Proto is set?

(note you can change PROXY_FIX_CONFIG)

dpgaspar avatar Dec 16 '19 11:12 dpgaspar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Feb 14 '20 11:02 stale[bot]