在nginx转发时保留原始域名( keep the Host header via nginx proxy_pass )

发布时间: 2014-05-07 01:41:00

最近的子项目越来越多,但是只有一个域名, 在做了nginx的跳转之后, 发现原来的域名会丢失,取代出现的是IP。

(with the growth of the sub-systems of my current project, there is a problem occurred: the origin domain name disappeared and it is replaced by the ip addresses , which is not liked by my workmates.  ) 

所以我们要保留原始域名,这货也叫 Host header.  (so the solution is to keep the origin domain name . aka host Header.  )

solution is : proxy_set_header Host $http_host;

    server {
        listen 80; 
        # this is the key !!!!! 
        proxy_set_header Host $host;
        location /client/pids {
        location /interface/client/pids {

refer to: and