[GH-ISSUE #2086] Forward subdomain based TCP Connections like ngrok #1661

Closed
opened 2026-05-05 13:03:42 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @schedutron on GitHub (Nov 19, 2020).
Original GitHub issue: https://github.com/fatedier/frp/issues/2086

First of all, thanks for building frp! It is of great utility for several of my projects.

The solution you want
I want to build a reverse proxy server that redirects TCP connections to different Raspberry Pi's based on the subdomain value. For example, if server's domain is frptest.com and I have 3 Raspberry Pi's I named pi-a, pi-b, pi-c, then I want

  • TCP request to pi-a.frptest.com getting routed to first Pi
  • TCP request to pi-b.frptest.com getting routed to second Pi, and so on.

I was able to do this successfully for HTTP requests by following this frp + nginx tutorial, but the server code running on my Pi's does not accept HTTP requests, it only accepts TCP ones.

Alternatives considered
I tried to use ngrok for this, by running ngrok tcp 8888 on each of my Raspberry Pi's. Now incoming TCP requests (which to be specific are for remote GPIO access) to the url ngrok provides (e.g. tcp://4.tcp.ngrok.io:18155) are routed successfully to the specific Pi.

I do not want to use ngrok because

  1. it's paid, the free version has a time limit
  2. url's are not configurable (I want nicknames to be assigned as subdomains).
  3. frp is more versatile.

I went through the README, but could not figure out a way to implement this.

Please point me to the correct documentation or frps / frpc configuration to make this possible. Thanks! 🙏

Originally created by @schedutron on GitHub (Nov 19, 2020). Original GitHub issue: https://github.com/fatedier/frp/issues/2086 <!-- From Chinese to English by machine translation, welcome to revise and polish. --> First of all, thanks for building frp! It is of great utility for several of my projects. **The solution you want** I want to build a reverse proxy server that redirects TCP connections to different Raspberry Pi's based on the subdomain value. For example, if server's domain is frptest.com and I have 3 Raspberry Pi's I named `pi-a`, `pi-b`, `pi-c`, then I want * TCP request to `pi-a.frptest.com` getting routed to first Pi * TCP request to `pi-b.frptest.com` getting routed to second Pi, and so on. I was able to do this successfully for HTTP requests by following [this frp + nginx tutorial](https://medium.com/@hc16/self-hosted-ngrok-alternative-using-frp-and-nginx-43ae6f325549), but the server code running on my Pi's does not accept HTTP requests, it only accepts TCP ones. **Alternatives considered** I tried to use `ngrok` for this, by running `ngrok tcp 8888` on each of my Raspberry Pi's. Now incoming TCP requests (which to be specific are for remote GPIO access) to the url ngrok provides (e.g. `tcp://4.tcp.ngrok.io:18155`) are routed successfully to the specific Pi. I do not want to use ngrok because 1. it's paid, the free version has a time limit 2. url's are not configurable (I want nicknames to be assigned as subdomains). 3. `frp` is more versatile. I went through the README, but could not figure out a way to implement this. Please point me to the correct documentation or `frps` / `frpc` configuration to make this possible. Thanks! 🙏
Author
Owner

@fatedier commented on GitHub (Nov 20, 2020):

tcp://4.tcp.ngrok.io:18155 It routes requests also by port?

https://github.com/fatedier/frp#access-your-computer-in-lan-by-ssh This will help you forward request to different Raspberry Pi's by port.

If you want to reuse the same port, this feature https://github.com/fatedier/frp#tcp-port-multiplexing can help you. However, you should connect your Raspberry Pi's by HTTP CONNECT protocol. The host of the HTTP CONNECT request will be used to match the proxy in frps.

<!-- gh-comment-id:730883635 --> @fatedier commented on GitHub (Nov 20, 2020): `tcp://4.tcp.ngrok.io:18155` It routes requests also by port? https://github.com/fatedier/frp#access-your-computer-in-lan-by-ssh This will help you forward request to different Raspberry Pi's by port. If you want to reuse the same port, this feature https://github.com/fatedier/frp#tcp-port-multiplexing can help you. However, you should connect your Raspberry Pi's by HTTP CONNECT protocol. The host of the HTTP CONNECT request will be used to match the proxy in frps.
Author
Owner

@schedutron commented on GitHub (Nov 22, 2020):

Thanks for the quick response @fatedier. Let me try that SSH approach with the GPIO server on my Raspberry Pi's (so the service won't be SSH but instead the remote GPIO service). Just wondering if using custom domains is possible with that approach (something like using subdomain_host config in conjunction with https://github.com/fatedier/frp#access-your-computer-in-lan-by-ssh). Will get back to you soon on this.

<!-- gh-comment-id:731815553 --> @schedutron commented on GitHub (Nov 22, 2020): Thanks for the quick response @fatedier. Let me try that SSH approach with the GPIO server on my Raspberry Pi's (so the service won't be SSH but instead the remote GPIO service). Just wondering if using custom domains is possible with that approach (something like using `subdomain_host` config in conjunction with https://github.com/fatedier/frp#access-your-computer-in-lan-by-ssh). Will get back to you soon on this.
Author
Owner

@fatedier commented on GitHub (Nov 23, 2020):

@schedutron It's not supported because no domain info is transfered in TCP protocol directly.

For HTTP, it transfers domain info in Host header.

For tcpmux(http connect), it transfers domain info in HTTP CONNECT host header.

frps should have a way to detect the domain info, so it can redirect your requests to correct backends.

<!-- gh-comment-id:731906835 --> @fatedier commented on GitHub (Nov 23, 2020): @schedutron It's not supported because no domain info is transfered in TCP protocol directly. For HTTP, it transfers domain info in `Host` header. For `tcpmux(http connect)`, it transfers domain info in `HTTP CONNECT` host header. frps should have a way to detect the domain info, so it can redirect your requests to correct backends.
Author
Owner

@schedutron commented on GitHub (Nov 27, 2020):

I see. Thanks for your prompt help! So I will only use frp for ssh purposes now - in a manner similar to the strategy in issue #338 , and will install a local client on each Raspberry Pi to interact with GPIO.

<!-- gh-comment-id:734785805 --> @schedutron commented on GitHub (Nov 27, 2020): I see. Thanks for your prompt help! So I will only use frp for ssh purposes now - in a manner similar to [the strategy in issue #338](https://github.com/fatedier/frp/issues/338) , and will install a local client on each Raspberry Pi to interact with GPIO.
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#1661
No description provided.