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

Rack::SslEnforcer options mess up with 'localhost' #64

Closed
hammady opened this issue Nov 25, 2013 · 11 comments
Closed

Rack::SslEnforcer options mess up with 'localhost' #64

hammady opened this issue Nov 25, 2013 · 11 comments

Comments

@hammady
Copy link

hammady commented Nov 25, 2013

Whatever options you put like :only_environments => 'production' or :only_hosts => 'blahblah', these will NOT be respected if you use 'localhost'. However, using 127.0.0.1 will behave correctly!

@tobmatth
Copy link
Owner

Thanks for reporting, i'll take a look this evening. Could you provide a failing test case?

@hammady
Copy link
Author

hammady commented Nov 25, 2013

I will try if I have time. Thanks for your help.

@hammady
Copy link
Author

hammady commented Nov 25, 2013

I created 2 cases for localhost and 127.0.0.1 but they both succeed. However, in the real environment where many layers are involved (DNS, thin/webrick/apache, ...) are involved, I am not sure how to reproduce this using your simple test environment. Maybe capybara with selenium should be used to replicate this?

@tobmatth
Copy link
Owner

Ok. What's the config.middleware.use line you use?

@hammady
Copy link
Author

hammady commented Nov 25, 2013

config.middleware.use Rack::SslEnforcer,
  :only_environments => 'production',
  :only_hosts => 'PRODUCTION_HOST',
  :only => [%r{^/users}, %r{^/admin}],
  :except => '/users/sign_out',
  :strict => true

@tobmatth
Copy link
Owner

tobmatth commented Dec 2, 2013

Sorry for the response lag, i've been pretty busy the last days.

config.middleware.use Rack::SslEnforcer,
  :only_environments => 'production',
  :only_hosts => 'www.example.org',
  :only => [%r{^/users}, %r{^/admin}],
  :except => '/users/sign_out',
  :strict => true

With the configuration line above, there should be no redirects at all in development environment, no matter if you point your browser to http://localhost/users or http://127.0.0.1/users. If i understand your issue properly, you are being redirected anyway?

@hammady
Copy link
Author

hammady commented Dec 3, 2013

I get redirected if used localhost but not 127.0.0.1.

Sent from my iPhone

On Dec 2, 2013, at 10:22 PM, Tobias Matthies [email protected] wrote:

Sorry for the response lag, i've been pretty busy the last days.

config.middleware.use Rack::SslEnforcer,
:only_environments => 'production',
:only_hosts => 'www.example.org',
:only => [%r{^/users}, %r{^/admin}],
:except => '/users/sign_out',
:strict => true
With the configuration line above, there should be no redirects at all in development environment, no matter if you point your browser to http://localhost/users or http://127.0.0.1/users. If i understand your issue properly, you are being redirected anyway?


Reply to this email directly or view it on GitHub.

@tobmatth
Copy link
Owner

tobmatth commented Dec 4, 2013

I've prepared a little sample application, which behaves as expected (from my side). Could you checkout https://github.com/tobmatth/rse-gh64 and test if this works for you?

@tobmatth
Copy link
Owner

Closing here due to inactivity, feel free to reopen...

@hammady
Copy link
Author

hammady commented Dec 17, 2013

It works perfectly. For my app as well. My best guess is that zeus could have had problems reloading the middleware.

@tobmatth
Copy link
Owner

Good to hear and thanks for your feedback...

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