ncr / rack-proxy

A request/response rewriting HTTP proxy. A Rack app.
MIT License
269 stars 94 forks source link

Request from SSL app to non-ssl application - How to disable SSL for redirected req? #83

Open geedon opened 5 years ago

geedon commented 5 years ago

I have an SSL enabled application and I'm redirecting a specific request to an older application, in order to avoid CORS issues. In fact this is a .Net application that will process print requests but it does not support SSL. The redirected request tries to connect with SSL resulting with the following in the Rails app logs...

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3/TLS write client hello: wrong version number):

The other application simply doesn't support SSL so its nothing to do with verifying SSL certificates or SSL version numbers.

Currently I'm using the following function, which works a treat when the app is not running in under SSL....

`def perform_request(env)

request = Rack::Request.new(env)

if request.path.include? "proxy_process_dispatch"

  env["http.read_timeout"] = (OFFICE_PRINT_TIMEOUT / 1000) - 1

  env["HTTP_HOST"] = OFFICE_IP + ':' + OFFICE_PRINT_SERVER_PORT     

  puts 'Redirecting dispatch process request to: ' + env["HTTP_HOST"] + '. Read timeout set to ' + env["http.read_timeout"].to_s

  env["REQUEST_PATH"] = "/?process=true"

  super(env)

else

  @app.call(env)

end

end

`

Can you help me to disable SSL for this specific request?

exo commented 4 years ago

I encountered this and managed to get the right behaviour by rewriting the header and rack config values in env that indicated the request was HTTPS before passing the request on to rack-proxy.

e.g.

    env["HTTP_X_FORWARDED_PROTO"] = "http"
    env["rack.url_scheme"] = "http"
    super(env)