diff --git a/README.md b/README.md index faac9d1d..03721391 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ frp is a fast reverse proxy to help you expose a local server behind a NAT or fi * [Support KCP Protocol](#support-kcp-protocol) * [Connection Pool](#connection-pool) * [Rewriting the Host Header](#rewriting-the-host-header) + * [Set Headers In HTTP Request](#set-headers-in-http-request) * [Get Real IP](#get-real-ip) * [Password protecting your web service](#password-protecting-your-web-service) * [Custom subdomain names](#custom-subdomain-names) @@ -485,7 +486,7 @@ This feature is fit for a large number of short connections. ### Rewriting the Host Header -When forwarding to a local port, frp does not modify the tunneled HTTP requests at all, they are copied to your server byte-for-byte as they are received. Some application servers use the Host header for determining which development site to display. For this reason, frp can rewrite your requests with a modified Host header. Use the `host_header_rewrite` switch to rewrite incoming HTTP requests. +When forwarding to a local port, frp does not modify the tunneled HTTP requests at all, they are copied to your server byte-for-byte as they are received. Some application servers use the Host header for determining which development site to display. For this reason, frp can rewrite your requests with a modified host header. Use the `host_header_rewrite` switch to rewrite incoming HTTP requests. ```ini # frpc.ini @@ -496,7 +497,24 @@ custom_domains = test.yourdomain.com host_header_rewrite = dev.yourdomain.com ``` -If `host_header_rewrite` is specified, the Host header will be rewritten to match the hostname portion of the forwarding address. +If `host_header_rewrite` is specified, the host header will be rewritten to match the hostname portion of the forwarding address. + +### Set Headers In HTTP Request + +You can set headers for proxy which type is `http`. + +```ini +# frpc.ini +[web] +type = http +local_port = 80 +custom_domains = test.yourdomain.com +host_header_rewrite = dev.yourdomain.com +header_X-From-Where = frp +``` + +Note that params which have prefix `header_` will be added to http request headers. +In this example, it will set header `X-From-Where: frp` to http request. ### Get Real IP diff --git a/README_zh.md b/README_zh.md index a4f95fee..ea8a15e4 100644 --- a/README_zh.md +++ b/README_zh.md @@ -34,6 +34,7 @@ frp 是一个可用于内网穿透的高性能的反向代理应用,支持 tcp * [底层通信可选 kcp 协议](#底层通信可选-kcp-协议) * [连接池](#连接池) * [修改 Host Header](#修改-host-header) + * [设置 http 请求的 header](#设置-http-请求的-header) * [获取用户真实 IP](#获取用户真实-ip) * [通过密码保护你的 web 服务](#通过密码保护你的-web-服务) * [自定义二级域名](#自定义二级域名) @@ -525,6 +526,22 @@ host_header_rewrite = dev.yourdomain.com 原来 http 请求中的 host 字段 `test.yourdomain.com` 转发到后端服务时会被替换为 `dev.yourdomain.com`。 +### 设置 http 请求的 header + +对于 `type = http` 的代理,可以设置在转发中动态添加的 header 参数。 + +```ini +# frpc.ini +[web] +type = http +local_port = 80 +custom_domains = test.yourdomain.com +host_header_rewrite = dev.yourdomain.com +header_X-From-Where = frp +``` + +对于参数配置中所有以 `header_` 开头的参数(支持同时配置多个),都会被添加到 http 请求的 header 中,根据如上的配置,会在请求的 header 中加上 `X-From-Where: frp`。 + ### 获取用户真实 IP 目前只有 **http** 类型的代理支持这一功能,可以通过用户请求的 header 中的 `X-Forwarded-For` 和 `X-Real-IP` 来获取用户真实 IP。 diff --git a/utils/version/version.go b/utils/version/version.go index e11d58e8..7ab09bef 100644 --- a/utils/version/version.go +++ b/utils/version/version.go @@ -19,7 +19,7 @@ import ( "strings" ) -var version string = "0.19.1" +var version string = "0.20.0" func Full() string { return version