ncr / rack-proxy

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

Just doesn't work #48

Closed joaomilho closed 8 years ago

joaomilho commented 10 years ago

I've just copied the example w/ example.com, added the "run" instruction, run rackup and... timeout.

require 'rack/proxy'

class Foo < Rack::Proxy

  def rewrite_env(env)
    env["HTTP_HOST"] = "example.com"

    env
  end

  def rewrite_response(triplet)
    status, headers, body = triplet

    headers["X-Foo"] = "Bar"

    triplet
  end

end

run Foo.new

Any idea?

joaomilho commented 10 years ago

Just figured out it's because my server is on port 9292. Is there any simple way to make it work running on this port? I really don't wanna have to run on 80 on development. Thanks!

ncr commented 10 years ago

Try the "backend" option in the constructor of the proxy like: Foo.new(backend: "http://your_host:9292")

joaomilho commented 9 years ago

Sorry for taking so long to reply, but it didn't work. Using port 80 seems like the only solution. Why is that?

nightscape commented 9 years ago

We're just experimenting with rack-proxy as well and it does have its subtleties ;) Can you try explicitly specifying the port like this?

env["HTTP_HOST"] = "example.com:80"
nicolasroy commented 9 years ago

Change the port for the proxied request. env['SERVER_PORT'] = '80' if env['SERVER_PORT'].to_i > 1000 This line above will allow you to request a domain while testing on localhost on a port higher that 1000

ncr commented 8 years ago

@joaomilho I hope your issue is resolved by now. Closing this issue.