Skip to content

Conversation

@sysuzhang
Copy link
Contributor

@sysuzhang sysuzhang commented Aug 25, 2017

When I use proxy-express as a reverse proxy server, if the target server will need to use the 'host' value in HTTP header. It usually refers to the request host, not the target server host. for example:
If I want to use www.b.com proxy pass to www.a.com server, then actually my server host name is www.b.com, but not www.a.com. If not, one problem is that:
when user visit to www.b.com, and the server www.a.com produces a 302 redirect, the redirect location value in HTTP header is www.a.com/path. The value comes from the host value setting in HTTP header. But the browser can't not redirect to www.a.com/path.
In other proxy server case, like nginx, when we use nginx as a reverse server , we usually config like this:
location ^~ /
{
proxy_pass http://192.168.1.112:8680/;
proxy_set_header Host $host;
proxy_set_header Port $server_port;
}
It means that I can pass the font host value to the target server.

But I found that, proxy.js set the host value directly use that target server host around line 155, just like:

req.headers.host = host;

I thought a lot why you set this value, I just find one situation that your target server is a virtual host website, We need to set the host as the target server host, then we can use another domain to visit. In other case I thought it is better not to change the host value.
Pls let me know more reasons about setting the host value, or maybe we can add an usege example to indicate the web-hosting's case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant