Add option to verify SSL

This commit is contained in:
James Hu 2016-10-11 22:11:08 -07:00
parent b7492a52ab
commit 1b2301a0c1
2 changed files with 16 additions and 5 deletions

View File

@ -58,6 +58,12 @@ You can also pass options into `reverse_proxy`
reverse_proxy "http://localhost:8000", path: "custom-path", headers: { 'X-Foo' => "Bar" }
```
If you'd like to bypass SSL verification
```ruby
reverse_proxy "http://localhost:8000", verify_ssl: false
```
Use this method to determine what version you're running
```ruby

View File

@ -40,7 +40,8 @@ module ReverseProxy
headers: {},
path: nil,
username: nil,
password: nil
password: nil,
verify_ssl: true
)
source_request = Rack::Request.new(env)
@ -78,8 +79,12 @@ module ReverseProxy
# within Varnish (503)
target_request['Accept-Encoding'] = nil
http_options = {}
http_options[:use_ssl] = (uri.scheme == "https")
http_options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if options[:verify_ssl]
# Make the request
Net::HTTP.start(uri.hostname, uri.port, use_ssl: (uri.scheme == "https"), :verify_mode: => OpenSSL::SSL::VERIFY_NONE) do |http|
Net::HTTP.start(uri.hostname, uri.port, http_options) do |http|
target_response = http.request(target_request)
end