redirects change https requests to http locations
See original GitHub issueI’m running Caravel in AWS with this configuration:
- ELB terminates SSL (and accepts only https requests)
- Docker container runs gunicorn + caravel
Many requests hang in the browser because the https request is redirected to a http location.
$ curl -Ik https://caravel.example.com/
HTTP/1.1 302 FOUND
Content-Length: 239
Content-Type: text/html; charset=utf-8
Date: Thu, 18 Aug 2016 16:30:20 GMT
Location: http://caravel.example.com/caravel/welcome
Server: gunicorn/19.6.0
Connection: keep-alive
I’m not sure if this is an issue with Caravel or upstream in Flask or Flask-AppBuilder.
I tried setting PREFERRED_URL_SCHEME = 'https'
in caravel_config.py hoping that would propagate to flask, but either it did not propagate, or it had no effect. (That config instructs flask what scheme to use when it cannot be determined.)
I think the right way to deal with this is to determine the protocol from the ‘X-Forwarded-Proto’ header. But I’m not sure if this is a bug in Caravel or Flask.
thanks, Dennis
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Redirects with HTTPS - DNSimple Blog
Understanding how to properly redirects with HTTP and HTTPS sites.
Read more >Redirections in HTTP - MDN Web Docs - Mozilla
In HTTP, redirection is triggered by a server sending a special redirect response to a request. Redirect responses have status codes that ...
Read more >How to Redirect HTTP to HTTPS - Semrush
This guide will take a deep dive into redirecting from HTTP to HTTPS. We'll look at what HTTP and HTTPS are, why redirects...
Read more >How to Redirect Website from HTTP to HTTPS? - Geekflare
Go to Page Rules · Click “Create Page Rule” · Enter the URL (put the asterisk, so redirection happens for all the URI)...
Read more >In Nginx, how can I rewrite all http requests to https while ...
In the simplest case your host will be fixed to be your service you want to send them to - this will do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey, I think redirects on ALB/Nginx level from 80 to 443 is a workaround, not a solution. I am not familiar with flask/gunicorn/whatever runs the Superset and anyway tried to force redirects go to https rather than http, but without success. I ended up with redirect solution on ALB, JUST for Superset. Is there ANY other way to force Superset to use https? Middleware or something?
For the record, I found the cause of the problem and the fix. When gunicorn is run on a different machine from the load balancer (nginx or ELB), it needs to be told explicitly to trust the X-Forwarded-* headers sent. gunicorn takes an option
--forwarded-allow-ips
which can either be a comma separated list of ip addresses, or “*” to trust all.I’m starting caravel with this command (with gunicorn running behind an ELB):
More details are in the gunicorn docs: http://docs.gunicorn.org/en/stable/deploy.html
cheers, Dennis