[GH-ISSUE #287] 怎么配置多端口,多应用的http代理? #208

Closed
opened 2026-05-05 12:00:13 -06:00 by gitea-mirror · 9 comments
Owner

Originally created by @jun4997 on GitHub (Mar 31, 2017).
Original GitHub issue: https://github.com/fatedier/frp/issues/287

比如我有 a,b,c三个应用,我要映射到三个一个域名下的三个端口上该怎么配置

Originally created by @jun4997 on GitHub (Mar 31, 2017). Original GitHub issue: https://github.com/fatedier/frp/issues/287 比如我有 a,b,c三个应用,我要映射到三个一个域名下的三个端口上该怎么配置
Author
Owner

@zhongheng666 commented on GitHub (Apr 5, 2017):

我的配置是这样的
Server:
[common]
bind_port=7000
vhost_http_port=server.port
dashboard_port=7500
dashboard_user=admin
dashboard_pwd=admin

[web]
type=http
custom_domains=examp1.com
auth_token=123

[web1]
type=http
custom_domains=examp2.com
auth_token=123

Client:
[common]
server_addr=server.ip
server_port=7000
auth_token=123

[web]
type=http
local_port=client.port1

[web1]
type=http
local_port=client.port2

按理说应该访问examp1.com的时候应该访问到的是client的port1的web服务,访问examp2.com的时候应该访问到client的port2的web服务,但是实际上都是访问到了port1的web服务。
所以我也是同问。

<!-- gh-comment-id:291865374 --> @zhongheng666 commented on GitHub (Apr 5, 2017): 我的配置是这样的 Server: [common] bind_port=7000 vhost_http_port=server.port dashboard_port=7500 dashboard_user=admin dashboard_pwd=admin [web] type=http custom_domains=examp1.com auth_token=123 [web1] type=http custom_domains=examp2.com auth_token=123 Client: [common] server_addr=server.ip server_port=7000 auth_token=123 [web] type=http local_port=client.port1 [web1] type=http local_port=client.port2 按理说应该访问examp1.com的时候应该访问到的是client的port1的web服务,访问examp2.com的时候应该访问到client的port2的web服务,但是实际上都是访问到了port1的web服务。 所以我也是同问。
Author
Owner

@swshag commented on GitHub (Apr 20, 2017):

[common]
server_addr = 10.0.0.0
server_port = 00000
privilege_token = *******

[web01]
type = http
local_ip = 127.0.0.0
local_port = 5000
use_gzip = true
use_encryption = true
pool_count = 20
privilege_mode = true
custom_domains = www.****.com
locations = /

[web02]
privilege_mode = true
type = http
local_ip = 127.0.0.0
local_port = 5005
custom_domains = www.****.com
locations = /news,/about

我也同问!

<!-- gh-comment-id:295749419 --> @swshag commented on GitHub (Apr 20, 2017): [common] server_addr = 10.0.0.0 server_port = 00000 privilege_token = ******* [web01] type = http local_ip = 127.0.0.0 local_port = 5000 use_gzip = true use_encryption = true pool_count = 20 privilege_mode = true custom_domains = www.****.com locations = / [web02] privilege_mode = true type = http local_ip = 127.0.0.0 local_port = 5005 custom_domains = www.****.com locations = /news,/about 我也同问!
Author
Owner

@openmynet commented on GitHub (Apr 23, 2017):

借助nginx实现啊

ngxin配置

server {
  listen 80;
  server_name app1.* app2.* app3.*;
  ## send request back to frps ##
  location / {
  client_max_body_size    1000m;  
  #frps端口8080
  proxy_pass http://127.0.0.1:8080;  
	proxy_redirect off;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $http_host;
	proxy_set_header X-NginX-Proxy true;
 }
}

frps配置

[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 8080
auth_token = openittoken
subdomain_host = testapp.com

[app1]
type = http
auth_token = openittoken
subdomain = app1
[app2]
type = http
auth_token = openittoken
subdomain = app2
[app3]
type = http
auth_token = openittoken
subdomain = app3

frpc 配置

[common]
server_addr = *.23.72.*
server_port = 7000
auth_token =openittoken

[app1]
type = http
local_port = 8081

[app2]
type = http
local_port = 8082

[app3]
type = http
local_port = 8083

http://app1.testapp.com => client:8081
http://app2.testapp.com => client:8082
http://app3.testapp.com => client:8083


1. 浏览器/App -> 2. 服务器 [ 2.1 nginx -> 2.2 frps ] -> 3. frpc

<!-- gh-comment-id:296438085 --> @openmynet commented on GitHub (Apr 23, 2017): 借助nginx实现啊 >ngxin配置 ```nginx server { listen 80; server_name app1.* app2.* app3.*; ## send request back to frps ## location / { client_max_body_size 1000m; #frps端口8080 proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; } } ``` > frps配置 ```ini [common] bind_addr = 0.0.0.0 bind_port = 7000 vhost_http_port = 8080 auth_token = openittoken subdomain_host = testapp.com [app1] type = http auth_token = openittoken subdomain = app1 [app2] type = http auth_token = openittoken subdomain = app2 [app3] type = http auth_token = openittoken subdomain = app3 ``` > frpc 配置 ```ini [common] server_addr = *.23.72.* server_port = 7000 auth_token =openittoken [app1] type = http local_port = 8081 [app2] type = http local_port = 8082 [app3] type = http local_port = 8083 ``` http://app1.testapp.com => client:8081 http://app2.testapp.com => client:8082 http://app3.testapp.com => client:8083 --- `1. 浏览器/App` -> `2. 服务器` [ `2.1 nginx` -> `2.2 frps` ] -> `3. frpc`
Author
Owner

@yfhust commented on GitHub (Oct 1, 2018):

弱弱问一下,服务器上运行多个frps实例可以解决这个问题吗?小白不懂nginx配置

<!-- gh-comment-id:425946054 --> @yfhust commented on GitHub (Oct 1, 2018): 弱弱问一下,服务器上运行多个frps实例可以解决这个问题吗?小白不懂nginx配置
Author
Owner

@snowdream commented on GitHub (Feb 23, 2019):

对于最新的版本,应该怎么解决这个问题。

<!-- gh-comment-id:466647438 --> @snowdream commented on GitHub (Feb 23, 2019): 对于最新的版本,应该怎么解决这个问题。
Author
Owner

@kunlong-luo commented on GitHub (Jan 17, 2020):

nginx 到底配置在服务器还是客户端?

<!-- gh-comment-id:575548750 --> @kunlong-luo commented on GitHub (Jan 17, 2020): nginx 到底配置在服务器还是客户端?
Author
Owner

@openmynet commented on GitHub (Jan 26, 2020):

nginx 到底配置在服务器还是客户端?

浏览器 -> 服务器【-> nginx -> frps】 -> frpc[ports...]

<!-- gh-comment-id:578474984 --> @openmynet commented on GitHub (Jan 26, 2020): > > > nginx 到底配置在服务器还是客户端? 浏览器 -> 服务器【-> nginx -> frps】 -> frpc[ports...]
Author
Owner

@shaojs321 commented on GitHub (Dec 23, 2021):

[通用] server_addr = 10.0.0.0 server_port = 00000 privilege_token = *******

[web01] type = http local_ip = 127.0.0.0 local_port = 5000 use_gzip = true use_encryption = true pool_count = 20 privilege_mode = true custom_domains = www.****.com location = /

[web02] privilege_mode = true type = http local_ip = 127.0.0.0 local_port = 5005 custom_domains = www.****.com 位置 = /news,/about

我也同问!

我如果没理解错,你这是同一台frpc有多个http服务,但是路由不一样,可以使用frp的URL功能https://gofrp.org/docs/features/http-https/route/

<!-- gh-comment-id:1000432946 --> @shaojs321 commented on GitHub (Dec 23, 2021): > [通用] server_addr = 10.0.0.0 server_port = 00000 privilege_token = ******* > > [web01] type = http local_ip = 127.0.0.0 local_port = 5000 use_gzip = true use_encryption = true pool_count = 20 privilege_mode = true custom_domains = [www.****.com](http://www.****.com) location = / > > [web02] privilege_mode = true type = http local_ip = 127.0.0.0 local_port = 5005 custom_domains = [www.****.com](http://www.****.com) 位置 = /news,/about > > 我也同问! 我如果没理解错,你这是同一台frpc有多个http服务,但是路由不一样,可以使用frp的URL功能https://gofrp.org/docs/features/http-https/route/
Author
Owner

@piwawa commented on GitHub (Apr 15, 2023):

借助nginx实现啊

ngxin配置

server {
  listen 80;
  server_name app1.* app2.* app3.*;
  ## send request back to frps ##
  location / {
  client_max_body_size    1000m;  
  #frps端口8080
  proxy_pass http://127.0.0.1:8080;  
	proxy_redirect off;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $http_host;
	proxy_set_header X-NginX-Proxy true;
 }
}

frps配置

[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 8080
auth_token = openittoken
subdomain_host = testapp.com

[app1]
type = http
auth_token = openittoken
subdomain = app1
[app2]
type = http
auth_token = openittoken
subdomain = app2
[app3]
type = http
auth_token = openittoken
subdomain = app3

frpc 配置

[common]
server_addr = *.23.72.*
server_port = 7000
auth_token =openittoken

[app1]
type = http
local_port = 8081

[app2]
type = http
local_port = 8082

[app3]
type = http
local_port = 8083

http://app1.testapp.com => client:8081 http://app2.testapp.com => client:8082 http://app3.testapp.com => client:8083

1. 浏览器/App -> 2. 服务器 [ 2.1 nginx -> 2.2 frps ] -> 3. frpc

./frpc -c frpc.ini
failed to parse proxy sd, err: custom_domains and subdomain should set at least one of them

frpc.ini 这样设置就报错了啊

<!-- gh-comment-id:1509868312 --> @piwawa commented on GitHub (Apr 15, 2023): > 借助nginx实现啊 > > > ngxin配置 > > ```nginx > server { > listen 80; > server_name app1.* app2.* app3.*; > ## send request back to frps ## > location / { > client_max_body_size 1000m; > #frps端口8080 > proxy_pass http://127.0.0.1:8080; > proxy_redirect off; > proxy_set_header X-Real-IP $remote_addr; > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; > proxy_set_header Host $http_host; > proxy_set_header X-NginX-Proxy true; > } > } > ``` > > > frps配置 > > ```ini > [common] > bind_addr = 0.0.0.0 > bind_port = 7000 > vhost_http_port = 8080 > auth_token = openittoken > subdomain_host = testapp.com > > [app1] > type = http > auth_token = openittoken > subdomain = app1 > [app2] > type = http > auth_token = openittoken > subdomain = app2 > [app3] > type = http > auth_token = openittoken > subdomain = app3 > ``` > > > frpc 配置 > > ```ini > [common] > server_addr = *.23.72.* > server_port = 7000 > auth_token =openittoken > > [app1] > type = http > local_port = 8081 > > [app2] > type = http > local_port = 8082 > > [app3] > type = http > local_port = 8083 > ``` > > http://app1.testapp.com => client:8081 http://app2.testapp.com => client:8082 http://app3.testapp.com => client:8083 > > `1. 浏览器/App` -> `2. 服务器` [ `2.1 nginx` -> `2.2 frps` ] -> `3. frpc` `./frpc -c frpc.ini` `failed to parse proxy sd, err: custom_domains and subdomain should set at least one of them` frpc.ini 这样设置就报错了啊
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#208
No description provided.