# 75.10.1 自定义Tomcat代理配置

如果使用的是Tomcat，你可以配置用于传输"forwarded"信息的headers名：

```
server.tomcat.remote-ip-header=x-your-remote-ip-header
server.tomcat.protocol-header=x-your-protocol-header
```

你也可以为Tomcat配置一个默认的正则表达式，用来匹配内部信任的代理。默认情况下，IP地址`10/8`，`192.168/16`，`169.254/16`和`127/8`是被信任的。通过设置`server.tomcat.internal-proxies`属性可以自定义，比如：

```
server.tomcat.internal-proxies=192\\.168\\.\\d{1,3}\\.\\d{1,3}
```

**注** 只有在使用配置文件时才需要双反斜线，如果使用YAML，只需要单个反斜线，比如`192\.168\.\d{1,3}\.\d{1,3}`。

**注** 将`internal-proxies`设置为空表示信任所有代理，不要在生产环境使用。

你可以完全控制Tomcat的`RemoteIpValve`配置，只要关掉自动配置（比如设置`server.use-forward-headers=false`）并在`TomcatServletWebServerFactory` bean添加一个新value实例。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/75.-embedded-web-servers/75.10-running-behind-a-front-end-proxy-server/75.10.1-customize-tomcats-proxy-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
