Skip to content
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

use_redirect always forcing redirect, even for HTTPS #88

Open
aripollak opened this issue May 20, 2016 · 2 comments
Open

use_redirect always forcing redirect, even for HTTPS #88

aripollak opened this issue May 20, 2016 · 2 comments

Comments

@aripollak
Copy link

aripollak commented May 20, 2016

Currently, I have the following configuration:

use Rack::SslEnforcer, hsts: true, redirect_to: 'https://www.example.com'

I'm using redirect_to because the site is behind a reverse proxy that routes different paths to different hosts, so the Host header that gets passed to this particular server is something totally different and not user-friendly, like ec2-1234.aws.amazon.com. I really only want Rack::SslEnforcer to redirect if the protocol is http instead of https. But currently because of redirect_required?, this actually causes a redirect loop. Is this behavior intentional? It seems like it's beyond the scope of this gem to always canonicalize the hostname.

I can work around the problem like this: ignore: -> (request) { request.env['HTTP_X_FORWARDED_PROTO'] == 'https' }

@aripollak aripollak changed the title use_redirect always forcing redirect, even for HTTP use_redirect always forcing redirect, even for HTTPS May 20, 2016
@tobmatth
Copy link
Owner

Hi,

seems like your reverse proxy does not set X-Forwarded* headers properly, maybe this helps:

https://github.com/tobmatth/rack-ssl-enforcer#nginx
#82

@aripollak
Copy link
Author

Which header in particular? It does seem to be setting those correctly, it just doesn't set Host to be the external-facing hostname.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants