[GH-ISSUE #233] 请问 local_ip 和 host_header_rewrite 的关系是什么? #159

Closed
opened 2026-05-05 11:53:23 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @likev on GitHub (Jan 16, 2017).
Original GitHub issue: https://github.com/fatedier/frp/issues/233

比如下述配置:

# frpc.ini                                                         
[web]
privilege_mode = true
type = http
local_ip = 192.168.0.6
local_port = 80
custom_domains = test.yourdomain.com
host_header_rewrite = dev.yourdomain.com

是否需要将 dev.yourdomain.com 的 A 记录指向 192.168.0.6?还是说要像 test.yourdomain.com 一样指向服务器的 IP?

Originally created by @likev on GitHub (Jan 16, 2017). Original GitHub issue: https://github.com/fatedier/frp/issues/233 比如下述配置: ```ini # frpc.ini [web] privilege_mode = true type = http local_ip = 192.168.0.6 local_port = 80 custom_domains = test.yourdomain.com host_header_rewrite = dev.yourdomain.com ``` 是否需要将 dev.yourdomain.com 的 A 记录指向 192.168.0.6?还是说要像 test.yourdomain.com 一样指向服务器的 IP?
Author
Owner

@fatedier commented on GitHub (Jan 16, 2017):

正常情况下是不需要使用这个参数的。

举个例子,比如你想通过 test.yourdomain.com 访问 www.baidu.com。 虽然这个请求被转发到了百度的服务器,但是你发送的 http 请求的 header 中的 host 参数是 test.yourdomain.com,百度的后端服务可能会进行检测,如果 host 不是 www.baidu.com 就拒绝,返回相应错误。

这个时候,如果你设置 host_header_rewrite = www.baidu.com,那么 frp 会将这个请求的 host 动态修改为 www.baidu.com,百度的服务器看到的就是正常的请求,才能正常访问。

如果你后端的 nginx 启用了虚拟主机这样的功能,需要根据 host 做路由,那么你才需要配置这个参数。

<!-- gh-comment-id:272865885 --> @fatedier commented on GitHub (Jan 16, 2017): 正常情况下是不需要使用这个参数的。 举个例子,比如你想通过 test.yourdomain.com 访问 `www.baidu.com`。 虽然这个请求被转发到了百度的服务器,但是你发送的 http 请求的 header 中的 host 参数是 `test.yourdomain.com`,百度的后端服务可能会进行检测,如果 host 不是 `www.baidu.com` 就拒绝,返回相应错误。 这个时候,如果你设置 `host_header_rewrite = www.baidu.com`,那么 frp 会将这个请求的 host 动态修改为 `www.baidu.com`,百度的服务器看到的就是正常的请求,才能正常访问。 如果你后端的 nginx 启用了虚拟主机这样的功能,需要根据 host 做路由,那么你才需要配置这个参数。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#159
No description provided.