{"action":"created","issue":{"url":"https://api.github.com/repos/elazarl/goproxy/issues/132","labels_url":"https://api.github.com/repos/elazarl/goproxy/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/elazarl/goproxy/issues/132/comments","events_url":"https://api.github.com/repos/elazarl/goproxy/issues/132/events","html_url":"https://github.com/elazarl/goproxy/issues/132","id":114736810,"number":132,"title":"Proxy can not properly pass the Header `Host` to origin server","user":{"login":"serika00","id":3762593,"avatar_url":"https://avatars.githubusercontent.com/u/3762593?v=3","gravatar_id":"","url":"https://api.github.com/users/serika00","html_url":"https://github.com/serika00","followers_url":"https://api.github.com/users/serika00/followers","following_url":"https://api.github.com/users/serika00/following{/other_user}","gists_url":"https://api.github.com/users/serika00/gists{/gist_id}","starred_url":"https://api.github.com/users/serika00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serika00/subscriptions","organizations_url":"https://api.github.com/users/serika00/orgs","repos_url":"https://api.github.com/users/serika00/repos","events_url":"https://api.github.com/users/serika00/events{/privacy}","received_events_url":"https://api.github.com/users/serika00/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-03T03:46:45Z","updated_at":"2015-11-03T07:17:08Z","closed_at":null,"body":"In my use case, I start the proxy on `127.0.0.1:8080` and issue the following command:\r\n`curl --proxy \"127.0.0.1:8080\" -H \"Host: domain.com\" \"http://130.130.10.10/ping\"`\r\n\r\nI expect that the origin server `130.130.10.10` would receive the request contain the Header `Host: domain.com`, but I observed the Header `Host` was erased by the proxy.\r\n\r\nAfter some search, `http.Request` has a `Host` field(https://golang.org/pkg/net/http/#Request), but it didn't help. \r\n\r\nIf `req.URL.Host` is not empty, the `req.Host` will be set to this value(so in the example above, the `req.Host` is set to `130.130.10.10`, but what I expect is `domain.com`), and the `Host` in `req.Header` will be deleted(https://golang.org/src/net/http/request.go?s=2057:8270#L703), the origin Header `Host` is not available anymore.\r\n\r\nThrough the document, it's true that the `Host` in Headers should be ignored on the origin server if the request URI contains the host(https://www.ietf.org/rfc/rfc2616.txt [section 5.2]), but not in case of the proxy.\r\n\r\nIs there a good way to solve this?"},"comment":{"url":"https://api.github.com/repos/elazarl/goproxy/issues/comments/153275240","html_url":"https://github.com/elazarl/goproxy/issues/132#issuecomment-153275240","issue_url":"https://api.github.com/repos/elazarl/goproxy/issues/132","id":153275240,"user":{"login":"elazarl","id":260258,"avatar_url":"https://avatars.githubusercontent.com/u/260258?v=3","gravatar_id":"","url":"https://api.github.com/users/elazarl","html_url":"https://github.com/elazarl","followers_url":"https://api.github.com/users/elazarl/followers","following_url":"https://api.github.com/users/elazarl/following{/other_user}","gists_url":"https://api.github.com/users/elazarl/gists{/gist_id}","starred_url":"https://api.github.com/users/elazarl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elazarl/subscriptions","organizations_url":"https://api.github.com/users/elazarl/orgs","repos_url":"https://api.github.com/users/elazarl/repos","events_url":"https://api.github.com/users/elazarl/events{/privacy}","received_events_url":"https://api.github.com/users/elazarl/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T07:17:08Z","updated_at":"2015-11-03T07:17:08Z","body":"Hmm... the Go stdlib is actively removing the information you need in this\ncase.\n\nIt already made almost impossible to support ICECAST exception.\n\nI think a good solution wouid be to copy net/http to a local package, and\nchange the necessary code to make it more flexible.\n\nWhat do you think?\n\nOn Tue, Nov 3, 2015 at 7:32 AM, serika00 <notifications@github.com> wrote:\n\n> Yes, I want the proxy contact foo.com with host name bar.com. But the\n> host name bar.com is set by the client, not the proxy, the proxy know\n> nothing about the host name, just deliver it.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/elazarl/goproxy/issues/132#issuecomment-153245897>.\n>\n"}}