[GH-ISSUE #2904] [Question] HTTPS-Proxy ... BAD GATEWAY message in Browser #2314

Closed
opened 2026-05-05 13:29:36 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @ikarstein on GitHub (Apr 20, 2022).
Original GitHub issue: https://github.com/fatedier/frp/issues/2904

Describe the feature request

Hi all,

I have a question regarding the configuration of FRPS/FRPC...

"Outside" my LAN I have a Debian VM with a public IP (v4). Inside my LAN I have a Windows machine.

On the Windows machine I run an ASP.NET app on IIS with HTTPS and SNI. This is all running.

I want to access this ASP.NET app from the internet. Also via HTTPS.

I started FRPS on the Debian VM and added "vhost_https_port=443" to the frps.ini

On the Windows machine I added this to frsc.ini:

[web01]
type = https
local_ip = 127.0.0.1
local_port = 443
use_encryption = false
use_compression = true
custom_domains = myapp.example.com
proxy_protocol_version = v2

frpc starts without problems and connects to frps (on the Debian VM).

On a third machine (Windows) I added an entry to the HOSTS file for "myapp.example.com" for the public IP of the Debian machine (FRPS).

When I try to access http://myapp.example.com I see the request on the Debian machine (FRPS) but in the browser (on the third machine) I get an error "ERR_CONNECTION_CLOSED".

What do I miss here? I cannot find my mistake.

Thank you all!

Regards
Ingo

Originally created by @ikarstein on GitHub (Apr 20, 2022). Original GitHub issue: https://github.com/fatedier/frp/issues/2904 ### Describe the feature request Hi all, I have a question regarding the configuration of FRPS/FRPC... "Outside" my LAN I have a Debian VM with a public IP (v4). Inside my LAN I have a Windows machine. On the Windows machine I run an ASP.NET app on IIS with HTTPS and SNI. This is all running. I want to access this ASP.NET app from the internet. Also via HTTPS. I started FRPS on the Debian VM and added "vhost_https_port=443" to the frps.ini On the Windows machine I added this to frsc.ini: [web01] type = https local_ip = 127.0.0.1 local_port = 443 use_encryption = false use_compression = true custom_domains = myapp.example.com proxy_protocol_version = v2 frpc starts without problems and connects to frps (on the Debian VM). On a third machine (Windows) I added an entry to the HOSTS file for "myapp.example.com" for the public IP of the Debian machine (FRPS). When I try to access http://myapp.example.com I see the request on the Debian machine (FRPS) but in the browser (on the third machine) I get an error "ERR_CONNECTION_CLOSED". What do I miss here? I cannot find my mistake. Thank you all! Regards Ingo
Author
Owner

@ikarstein commented on GitHub (Apr 20, 2022):

Now I found the plugin "https2https"

I changed the config:

[web01]
type = https
#local_ip = 127.0.0.1
#local_port = 443
use_encryption = false
use_compression = false
custom_domains = myapp.example.com
proxy_protocol_version = v2
plugin = https2https
plugin_local_addr = 127.0.0.1:443
plugin_crt_path = c:\ssl\myapp.example.com.crt
plugin_key_path = c:\ssl\myapp.example.com.key
plugin_host_header_rewrite = myapp.example.com
plugin_header_X-From-Where = frp

On the third machine I use the browser to access https://myapp.example.com.

Now I get a 502 "Bad Gateway" error.

<!-- gh-comment-id:1104208183 --> @ikarstein commented on GitHub (Apr 20, 2022): Now I found the plugin "https2https" I changed the config: [web01] type = https #local_ip = 127.0.0.1 #local_port = 443 use_encryption = false use_compression = false custom_domains = myapp.example.com proxy_protocol_version = v2 plugin = https2https plugin_local_addr = 127.0.0.1:443 plugin_crt_path = c:\ssl\myapp.example.com.crt plugin_key_path = c:\ssl\myapp.example.com.key plugin_host_header_rewrite = myapp.example.com plugin_header_X-From-Where = frp On the third machine I use the browser to access https://myapp.example.com. **Now I get a 502 "Bad Gateway" error.**
Author
Owner

@fatedier commented on GitHub (Apr 21, 2022):

Why you set proxy_protocol_version = v2?

<!-- gh-comment-id:1104634470 --> @fatedier commented on GitHub (Apr 21, 2022): Why you set `proxy_protocol_version = v2`?
Author
Owner

@ikarstein commented on GitHub (Apr 21, 2022):

Thank you for your answer!

... because I saw it in a sample config. I already tried it without this line.

<!-- gh-comment-id:1104723139 --> @ikarstein commented on GitHub (Apr 21, 2022): Thank you for your answer! ... because I saw it in a sample config. I already tried it without this line.
Author
Owner

@ikarstein commented on GitHub (Apr 21, 2022):

The current (and also not working) config is:

#frpc.ini
[common]
server_addr = x.x.x.x
server_port = yyyy
token=abc
log_level = trace
tls_enable = true
tls_cert_file = c:\ssl\client.crt
tls_key_file = c:\ssl\client.key

[web01]
type = https
#local_ip = 127.0.0.1
#local_port = 443
#use_encryption = false
#use_compression = false
custom_domains = myapp.example.com
#proxy_protocol_version = v2
plugin = https2https 
plugin_local_addr = 127.0.0.1:443
plugin_crt_path = c:\ssl\myapp.example.com.crt
plugin_key_path = c:\ssl\myapp.example.com.key
plugin_host_header_rewrite = myapp.example.com
plugin_header_X-From-Where = frp

As you can see I added TLS for the connection between FRPC and FRPS. The handshake seems to be okay.

On FRPC machine I get this log message:
2022/04/20 23:41:11 [D] [proxy.go:784] [XXXXXXXXXXXXXXXX] [web01] handle by plugin: https2http

Without a "s" behind the second "http" in the plugin name... Is that correct?

<!-- gh-comment-id:1104777590 --> @ikarstein commented on GitHub (Apr 21, 2022): The current (and also not working) config is: ``` #frpc.ini [common] server_addr = x.x.x.x server_port = yyyy token=abc log_level = trace tls_enable = true tls_cert_file = c:\ssl\client.crt tls_key_file = c:\ssl\client.key [web01] type = https #local_ip = 127.0.0.1 #local_port = 443 #use_encryption = false #use_compression = false custom_domains = myapp.example.com #proxy_protocol_version = v2 plugin = https2https plugin_local_addr = 127.0.0.1:443 plugin_crt_path = c:\ssl\myapp.example.com.crt plugin_key_path = c:\ssl\myapp.example.com.key plugin_host_header_rewrite = myapp.example.com plugin_header_X-From-Where = frp ``` As you can see I added TLS for the connection between FRPC and FRPS. The handshake seems to be okay. On FRPC machine I get this log message: `2022/04/20 23:41:11 [D] [proxy.go:784] [XXXXXXXXXXXXXXXX] [web01] handle by plugin: https2http` Without a "s" behind the second "http" in the plugin name... Is that correct?
Author
Owner

@fatedier commented on GitHub (Apr 21, 2022):

You can try your original configs:

[web01]
type = https
local_ip = 127.0.0.1
local_port = 443
custom_domains = myapp.example.com
<!-- gh-comment-id:1104785813 --> @fatedier commented on GitHub (Apr 21, 2022): You can try your original configs: ``` [web01] type = https local_ip = 127.0.0.1 local_port = 443 custom_domains = myapp.example.com ```
Author
Owner

@ikarstein commented on GitHub (Apr 21, 2022):

This was my first approach.

...But now it works !!!

I am confused. I still had that first configuration at the end of my
FRPC.INI file.

THANK YOU!

<!-- gh-comment-id:1104795656 --> @ikarstein commented on GitHub (Apr 21, 2022): This was my first approach. ...But now it works !!! I am confused. I still had that first configuration at the end of my FRPC.INI file. THANK YOU!
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#2314
No description provided.