[GH-ISSUE #1071] Allow dashboard over same port #843

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

Originally created by @luckydonald on GitHub (Jan 31, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1071

Feature Request.

Currently, we can already combine vhost_http_port and bind_port, as the websocket uses /~!frp as route.
It would be great to be able to attach the admin interface to the same port at e.g. /dashboard.

It could look like the following:

[common]
# The API port of frp
bind_port = 80

# The HTTP port (proxy to you)
vhost_http_port = 80

# dashboard
dashboard_port = 80
dashboard_route = /admin
dashboard_user = admin_user
dashboard_pwd = security_sausage

Notice the new dashboard_route element.
Also a dashboard_host could be helpful, to use the Host header.

My current config

You know, for completeness sake.
server.ini:

[common]
# The API port of frp
bind_port = {{ .Envs.PORT }}

# The HTTP port (proxy to you)
vhost_http_port = {{ .Envs.PORT }}

# whitelist ports
# allow_ports={{ .Envs.PORT }}

# security token
token =  {{ .Envs.TOKEN }}

# dashboard
dashboard_port = 12314
# dashboard's username and password are both optional,if not set, default is admin.
dashboard_user = admin_user
dashboard_pwd = security_sausage

client.ini:

[common]
server_addr = {{ .Envs.SERVER_HOST }}
server_port = {{ .Envs.SERVER_PORT }}
token =  {{ .Envs.TOKEN }}
login_fail_exit = false
protocol = websocket

[web]
type = http
local_ip = {{ .Envs.LOCAL_HOST }}
local_port = {{ .Envs.LOCAL_PORT }}
remote_port = {{ .Envs.SERVER_PORT }}
locations = /
custom_domains = {{ .Envs.SERVER_HOST }}

Obviously the used password is fake :D
But it would be so cool!

Originally created by @luckydonald on GitHub (Jan 31, 2019). Original GitHub issue: https://github.com/fatedier/frp/issues/1071 Feature Request. Currently, we can [already](https://github.com/fatedier/frp#port-reuse) combine `vhost_http_port` and `bind_port`, as the websocket uses `/~!frp` as route. It would be great to be able to attach the admin interface to the same port at e.g. `/dashboard`. It could look like the following: ```ini [common] # The API port of frp bind_port = 80 # The HTTP port (proxy to you) vhost_http_port = 80 # dashboard dashboard_port = 80 dashboard_route = /admin dashboard_user = admin_user dashboard_pwd = security_sausage ``` Notice the new `dashboard_route` element. Also a `dashboard_host` could be helpful, to use the `Host` header. #### My current config You know, for completeness sake. `server.ini`: ```ini [common] # The API port of frp bind_port = {{ .Envs.PORT }} # The HTTP port (proxy to you) vhost_http_port = {{ .Envs.PORT }} # whitelist ports # allow_ports={{ .Envs.PORT }} # security token token = {{ .Envs.TOKEN }} # dashboard dashboard_port = 12314 # dashboard's username and password are both optional,if not set, default is admin. dashboard_user = admin_user dashboard_pwd = security_sausage ``` `client.ini`: ```ini [common] server_addr = {{ .Envs.SERVER_HOST }} server_port = {{ .Envs.SERVER_PORT }} token = {{ .Envs.TOKEN }} login_fail_exit = false protocol = websocket [web] type = http local_ip = {{ .Envs.LOCAL_HOST }} local_port = {{ .Envs.LOCAL_PORT }} remote_port = {{ .Envs.SERVER_PORT }} locations = / custom_domains = {{ .Envs.SERVER_HOST }} ``` <sup><sub>Obviously the used password is fake :D<br>But it would be so cool!</sub></sup>
Author
Owner

@fatedier commented on GitHub (Feb 1, 2019):

I have considered this feature and the problem is how to distinguish dashboard requests from v_host_http port requests. Your proposal with dashboard_route will affect the dashboard api prefix which is /api/xxx now. I'm not sure if it's simple and stable to allow users redefine it. As you know, dashboard js code will call these apis with hardcode api prefix.

Also in some cases, owners only want to bind dashboard port with a local address such as 127.0.0.1dashboard_addr can be different with bind_addr.

We may need a more reliable solution.

<!-- gh-comment-id:459573985 --> @fatedier commented on GitHub (Feb 1, 2019): I have considered this feature and the problem is how to distinguish dashboard requests from `v_host_http` port requests. Your proposal with `dashboard_route` will affect the dashboard api prefix which is `/api/xxx` now. I'm not sure if it's simple and stable to allow users redefine it. As you know, dashboard js code will call these apis with hardcode api prefix. Also in some cases, owners only want to bind dashboard port with a local address such as `127.0.0.1`。`dashboard_addr` can be different with `bind_addr`. We may need a more reliable solution.
Author
Owner

@luckydonald commented on GitHub (Feb 1, 2019):

Maybe we could change the (default) API endpoint to /~!api/ to minimize collision.

The javascript could define and use a global variable var API_URL = 'http://example.com/~!api'. This could inserted in a server template, or something.

<script>
    window.API_URL = "{{ .Config.dashboard_route }}";
</script>

<!-- vue stuff -->

and

fetch(API_URL + '/serverinfo', {credentials: 'include'})
<!-- gh-comment-id:459590836 --> @luckydonald commented on GitHub (Feb 1, 2019): Maybe we could change the (default) API endpoint to `/~!api/` to minimize collision. The javascript could define and use a global variable `var API_URL = 'http://example.com/~!api'`. This could inserted in a server template, or something. ```html <script> window.API_URL = "{{ .Config.dashboard_route }}"; </script> <!-- vue stuff --> ``` and ```js fetch(API_URL + '/serverinfo', {credentials: 'include'}) ```
Author
Owner

@luckydonald commented on GitHub (Feb 1, 2019):

An alternative to rendering a template with the dashboard url could be asking the already existing /~!frp websocket for it.

<!-- gh-comment-id:459878521 --> @luckydonald commented on GitHub (Feb 1, 2019): An alternative to rendering a template with the dashboard url could be asking the already existing `/~!frp` websocket for it.
Author
Owner

@fatedier commented on GitHub (Feb 2, 2019):

The websocket url prefix /~!frp is only used between frpc and frps, no one will see that.

/ ~!api/ looks strange for users that they will used it to call the apis.

The dashboard homepage is http://127.0.0.1:7500, no prefix.

<!-- gh-comment-id:459927423 --> @fatedier commented on GitHub (Feb 2, 2019): The websocket url prefix `/~!frp` is only used between frpc and frps, no one will see that. `/ ~!api/` looks strange for users that they will used it to call the apis. The dashboard homepage is `http://127.0.0.1:7500`, no prefix.
Author
Owner

@ogimenezb commented on GitHub (Feb 21, 2019):

How about using a config like:

[common]
# The API port of frp
bind_port = 80

# The HTTP port (proxy to you)
vhost_http_port = 80

# dashboard
dashboard_port = 80
dashboard_vhost = admin
dashboard_user = admin_user
dashboard_pwd = security_sausage

best of both worlds

<!-- gh-comment-id:466126812 --> @ogimenezb commented on GitHub (Feb 21, 2019): How about using a config like: ``` [common] # The API port of frp bind_port = 80 # The HTTP port (proxy to you) vhost_http_port = 80 # dashboard dashboard_port = 80 dashboard_vhost = admin dashboard_user = admin_user dashboard_pwd = security_sausage ``` best of both worlds
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#843
No description provided.