Last active
September 24, 2016 21:30
-
-
Save homakov/ea001418ecf15319a3e0 to your computer and use it in GitHub Desktop.
config.ru
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is used by Rack-based servers to start the application. | |
require ::File.expand_path('../config/environment', __FILE__) | |
#prevents DNS rebinding attacks | |
class DNSBinding | |
VALID_HOSTS = %w{localhost:9292 myshop.dev:3000 myshopprod.com} | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if VALID_HOSTS.include? env['HTTP_HOST'] | |
@app.call(env) | |
else | |
[403,{},["Invalid Host"]] | |
end | |
end | |
end | |
use DNSBinding | |
run Rails.application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@why-el i suggest it! it should be in core