From 3e6f825a9df29cbfd479753ef364ff7d73f3051a Mon Sep 17 00:00:00 2001 From: Guy Lewin Date: Sun, 16 Feb 2020 18:06:14 +0200 Subject: [PATCH] Update readme to talk about tcp multiplexing --- README.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c65d7fa2..9691fa12 100644 --- a/README.md +++ b/README.md @@ -714,7 +714,7 @@ proxy_protocol_version = v2 You can enable Proxy Protocol support in nginx to expose user's real IP in HTTP header `X-Real-IP`, and then read `X-Real-IP` header in your web service for the real IP. -### Require HTTP Basic auth (password) for web services +### Require HTTP Basic Auth (Password) for Web Services Anyone who can guess your tunnel URL can access your local web server unless you protect it with a password. @@ -734,7 +734,7 @@ http_pwd = abc Visit `http://test.example.com` in the browser and now you are prompted to enter the username and password. -### Custom subdomain names +### Custom Subdomain Names It is convenient to use `subdomain` configure for http and https types when many people share one frps server. @@ -757,7 +757,7 @@ Now you can visit your web service on `test.frps.com`. Note that if `subdomain_host` is not empty, `custom_domains` should not be the subdomain of `subdomain_host`. -### URL routing +### URL Routing frp supports forwarding HTTP requests to different backend web services by url routing. @@ -780,6 +780,49 @@ locations = /news,/about HTTP requests with URL prefix `/news` or `/about` will be forwarded to **web02** and other requests to **web01**. +### TCP Multiplexing + +frp supports receiving TCP sockets directed to different proxies on a single port on frps, similar to `vhost_http_port` and `vhost_https_port`. + +When setting `vhost_tcp_port` to anything other than 0 in frps under `[common]`, frps will listen on this port for HTTP CONNECT requests. + +The host of the HTTP CONNECT request will be used to match the proxy in frps. Proxy hosts can be configured in frpc by configuring `custom_domain` and / or `subdomain` under tcp proxies. + +For example: + +```ini +# frps.ini +[common] +bind_port = 7000 +vhost_tcp_port = 1337 +``` + +```ini +# frpc.ini +[common] +server_addr = x.x.x.x +server_port = 7000 + +[proxy1] +type = tcp +# Ignored since vhost_tcp_port is set - that's the only port that'll be used +remote_port = 0 +custom_domains = test1 + +[proxy2] +type = tcp +# Ignored since vhost_tcp_port is set - that's the only port that'll be used +remote_port = 0 +custom_domains = test2 +``` + +In the above configuration - frps can be contacted on port 1337 with a HTTP CONNECT header such as: + +``` +CONNECT test1 HTTP/1.1\r\n\r\n +``` +and the connection will be transferred to `proxy1`. + ### Connecting to frps via HTTP PROXY frpc can connect to frps using HTTP proxy if you set OS environment variable `HTTP_PROXY`, or if `http_proxy` is set in frpc.ini file.