> For the complete documentation index, see [llms.txt](https://bohans.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bohans.gitbook.io/devops/ngnix/ji-chu-zhi-shi/4.-nginx-fu-wu-qi-de-dai-li-fu-wu/4.3-nginx-fu-wu-qi-de-fan-xiang-dai-li-fu-wu/fan-xiang-dai-li-de-ji-ben-she-zhi-de-21-ge-zhi-ling/proxy_set_header.md).

# proxy\_set\_header

<mark style="color:blue;">**proxy\_set\_header**</mark>指令可以<mark style="color:blue;">**更改Nginx服务器接收到的客户端请求的请求头信息，然后将新的请求头发送给被代理的服务器**</mark>。其语法结构为：

```nginx
proxy_set_header field value;
```

* <mark style="color:blue;">**field**</mark>，要更改的信息所在的头域。
* <mark style="color:blue;">**value**</mark>，更改的值，支持使用文本、变量或者变量的组合。

默认情况下，该指令的设置为：

```nginx
proxy_set_header Host  $proxy_host;
proxy_set_header Connection  close;
```

{% hint style="info" %}
**HTTP请求的首部字段**<mark style="color:blue;">**Host**</mark>**会告知服务器，请求的资源所处的互联网主机名和端口号。**

<mark style="color:blue;">**$proxy\_host**</mark> 指的是Nginx服务器的地址，若让Host变更为被代理服务器（客户端的目标服务器）的地址，应使用<mark style="color:blue;">**$host**</mark>。
{% endhint %}
