openresty / headers-more-nginx-module

Set, add, and clear arbitrary output headers in NGINX http servers
1.65k stars 221 forks source link

more_set_input_headers/more_clear_input_headers cannot set header "Host" #109

Closed LuoHaibin closed 4 years ago

LuoHaibin commented 4 years ago

Build:

Config:

    server {
        listen       80;

        location / {
            proxy_pass http://192.168.0.103:81;
            more_set_input_headers 'Host: foo';
            more_set_input_headers 'o-Host: foo';
        }
    }

Request:

$ curl -svo /dev/null http://127.0.0.1
*   Trying 127.0.0.1:80...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.18.0
< Date: Sun, 19 Jul 2020 06:39:30 GMT
< Content-Type: text/html
< Content-Length: 612
< Connection: keep-alive
< Last-Modified: Tue, 21 Jan 2020 13:39:42 GMT
< ETag: "5e26ff1e-264"
< Accept-Ranges: bytes
<
{ [612 bytes data]
* Connection #0 to host 127.0.0.1 left intact

Proxied Server:

GET / HTTP/1.0
Host: 192.168.0.103:81
Connection: close
User-Agent: curl/7.68.0
Accept: */*
o-Host: foo

more_set_input_headers 'o-Host: foo'; worked, but more_set_input_headers 'Host: foo'; didn't

ajs124 commented 4 years ago

I'm running into the exact same issue. Even the example for setting Host from the Readme doesn't seem to be working. How did you solve this in the end?