Last active
April 22, 2016 19:50
-
-
Save mikechau/6d705e1b261ecd601ea5ceecd7b72b52 to your computer and use it in GitHub Desktop.
reverse_proxy_rack
This file contains 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
require 'rack/handler/thin' | |
require 'rack/reverse_proxy' | |
require 'pathname' | |
cert = Pathname(__dir__).join('ssl/server.crt').to_s | |
pkey = Pathname(__dir__).join('ssl/server.key').to_s | |
app = Rack::Builder.app do | |
use Rack::ReverseProxy do | |
reverse_proxy_options preserve_host: true, verify_peer: OpenSSL::SSL::VERIFY_NONE | |
reverse_proxy '/', 'http://127.0.0.1:9999/' | |
end | |
run lambda { |env| [ 200, {'Content-Type' => 'text/plain'}, "y hallo thar" ] } | |
end | |
Rack::Handler::Thin.run(app, { | |
Port: 443, | |
Host: '0.0.0.0' | |
}) do |server| | |
server.ssl = true | |
server.ssl_options = { | |
cert_chain_file: cert, | |
private_key_file: pkey, | |
verify_peer: false | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo ruby reverse_proxy_rack.rb
orrvmsudo ruby reverse_proxy_rack.rb
.