[GH-ISSUE #1203] host_header_rewrite doesn't support port rewrite #945

Closed
opened 2026-05-05 12:36:01 -06:00 by gitea-mirror · 1 comment
Owner

Originally created by @bomblet2 on GitHub (Apr 19, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1203

I setup a frp server with subdomian_host frps.aaa.com
then I add some subdomains to my frp client.
[bcddphone]
type = http
local_port = 8085
subdomain = bcddphone
Everyting goes well when I request my url http://bcddphone.frps.aaa.com/aaa.aspx
But when my http server use redirect command 302 to redirect page.
The page may redirect to http://bcddphone.frps.aaa.com:8085/bbb.aspx
I've tried to add param
host_header_rewrite bcddphone.frps.aaa.com:80
But it doesn't work.

Originally created by @bomblet2 on GitHub (Apr 19, 2019). Original GitHub issue: https://github.com/fatedier/frp/issues/1203 I setup a frp server with subdomian_host frps.aaa.com then I add some subdomains to my frp client. [bcddphone] type = http local_port = 8085 subdomain = bcddphone Everyting goes well when I request my url http://bcddphone.frps.aaa.com/aaa.aspx But when my http server use redirect command 302 to redirect page. The page may redirect to http://bcddphone.frps.aaa.com:8085/bbb.aspx I've tried to add param host_header_rewrite bcddphone.frps.aaa.com:80 But it doesn't work.
Author
Owner

@bomblet2 commented on GitHub (Apr 20, 2019):

It seems ngrok can overwrite http header HOST with both host and port.

ngrok http -host-header=rewrite site.dev:80

----------- ngrok documents -----------

Rewriting the Host header

When forwarding to a local port, ngrok 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 like WAMP, MAMP and pow use the Host header for determining which development site to display. For this reason, ngrok can rewrite your requests with a modified Host header. Use the -host-header switch to rewrite incoming HTTP requests.

If rewrite is specified, the Host header will be rewritten to match the hostname portion of the forwarding address. Any other value will cause the Host header to be rewritten to that value.
Rewrite the Host header to 'site.dev'

ngrok http -host-header=rewrite site.dev:80

<!-- gh-comment-id:485060742 --> @bomblet2 commented on GitHub (Apr 20, 2019): It seems ngrok can overwrite http header HOST with both host and port. ngrok http -host-header=rewrite site.dev:80 ----------- ngrok documents ----------- Rewriting the Host header When forwarding to a local port, ngrok 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 like WAMP, MAMP and pow use the Host header for determining which development site to display. For this reason, ngrok can rewrite your requests with a modified Host header. Use the -host-header switch to rewrite incoming HTTP requests. If rewrite is specified, the Host header will be rewritten to match the hostname portion of the forwarding address. Any other value will cause the Host header to be rewritten to that value. Rewrite the Host header to 'site.dev' ngrok http -host-header=rewrite site.dev:80
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#945
No description provided.