[GH-ISSUE #2213] How to get the VirtualHost serverName of local Apache in PHP using https2http plug-in #1762

Closed
opened 2026-05-05 13:08:14 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @phaserwork on GitHub (Jan 25, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2213

When I use PHP to get the protocol://serverName, the result is http://127.0.0.1. I want to get https://www.xxx.com how to do it?

frps.ini

[common]
bind_port = 7000
vhost_https_port = 443

frpc.ini

[common]
server_addr = x.x.x.x
server_port = 7000

[www]
type = https
custom_domains = www.xxx.com

plugin = https2http
plugin_local_addr = 127.0.0.1:80

# HTTPS 证书相关的配置
plugin_crt_path = ./xxx.crt
plugin_key_path = ./xxx.key
plugin_host_header_rewrite = 127.0.0.1
plugin_header_X-From-Where = frp

windows
hosts

127.0.0.1 www.xxx.com

httpd-vhosts.conf with wampserver

<VirtualHost *:80>
    ServerName www.xxx.com
    DocumentRoot "e:/uimb/public"
    <Directory  "e:/uimb/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>
Originally created by @phaserwork on GitHub (Jan 25, 2021). Original GitHub issue: https://github.com/fatedier/frp/issues/2213 ### **When I use PHP to get the protocol://serverName, the result is http://127.0.0.1. I want to get https://www.xxx.com how to do it?** `frps.ini` ``` [common] bind_port = 7000 vhost_https_port = 443 ``` `frpc.ini` ``` [common] server_addr = x.x.x.x server_port = 7000 [www] type = https custom_domains = www.xxx.com plugin = https2http plugin_local_addr = 127.0.0.1:80 # HTTPS 证书相关的配置 plugin_crt_path = ./xxx.crt plugin_key_path = ./xxx.key plugin_host_header_rewrite = 127.0.0.1 plugin_header_X-From-Where = frp ``` windows `hosts` ``` 127.0.0.1 www.xxx.com ``` `httpd-vhosts.conf` with `wampserver` ``` <VirtualHost *:80> ServerName www.xxx.com DocumentRoot "e:/uimb/public" <Directory "e:/uimb/public/"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost> ```
Author
Owner

@fatedier commented on GitHub (Jan 26, 2021):

Remove plugin_host_header_rewrite = 127.0.0.1

<!-- gh-comment-id:767544677 --> @fatedier commented on GitHub (Jan 26, 2021): Remove `plugin_host_header_rewrite = 127.0.0.1`
Author
Owner

@phaserwork commented on GitHub (Jan 26, 2021):

Remove plugin_host_header_rewrite = 127.0.0.1

Thank you! finally, I understand.
However, for the protocol issue, my local must also be https. Like https2https, otherwise the protocol obtained in PHP is still http.

<!-- gh-comment-id:767874905 --> @phaserwork commented on GitHub (Jan 26, 2021): > Remove `plugin_host_header_rewrite = 127.0.0.1` Thank you! finally, I understand. However, for the `protocol` issue, my local must also be `https`. Like `https2https`, otherwise the `protocol` obtained in PHP is still `http`.
Author
Owner

@fatedier commented on GitHub (Jan 27, 2021):

You can just use https without https2http plugin. However, you can't use custom certs for it.

Or you can wait for next release version, https2https will be supported.

<!-- gh-comment-id:768000298 --> @fatedier commented on GitHub (Jan 27, 2021): You can just use `https` without `https2http` plugin. However, you can't use custom certs for it. Or you can wait for next release version, `https2https` will be supported.
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#1762
No description provided.