Example Usage
Firstly, download the latest programs from
to enable this feature:
[common]
dashboard_port = 7500
# dashboard's username and password are both optional,if not set, default is admin.
dashboard_user = admin
dashboard_pwd = adminThen visit http://[server_addr]:7500 to see the dashboard, with username and password both being admin by default.
Authenticating the Client
There are 2 authentication methods to authenticate frpc with frps.
You can decide which one to use by configuring authentication_method under [common] in frpc.ini and frps.ini.
Configuring authenticate_heartbeats = true under [common] will use the configured authentication method to add and validate authentication on every heartbeat between frpc and frps.
Configuring authenticate_new_work_conns = true under [common] will do the same for every new work connection between frpc and frps.
Token Authentication
When specifying authentication_method = token under [common] in frpc.ini and frps.ini - token based authentication will be used.
Make sure to specify the same token in the [common] section in frps.ini and frpc.ini for frpc to pass frps validation
OIDC Authentication
When specifying authentication_method = oidc under [common] in frpc.ini and frps.ini - OIDC based authentication will be used.
OIDC stands for OpenID Connect, and the flow used is called Grant.
To use this authentication type - configure frpc.ini and frps.ini as follows:
# frps.ini
[common]
authentication_method = oidc
oidc_issuer = https://example-oidc-issuer.com/
oidc_audience = https://oidc-audience.com/.default# frpc.ini
[common]
authentication_method = oidc
oidc_client_id = 98692467-37de-409a-9fac-bb2585826f18 # Replace with OIDC client ID
oidc_client_secret = oidc_secret
oidc_audience = https://oidc-audience.com/.default
oidc_token_endpoint_url = https://example-oidc-endpoint.com/oauth2/v2.0/tokenEncryption and Compression
The features are off by default. You can turn on in the future.
Bandwidth Limit
For Each Proxy
# frpc.ini
[ssh]
type = tcp
local_port = 22
remote_port = 6000
bandwidth_limit = 1MBSet bandwidth_limit in each proxy's configure to enable this feature. Supported units are MB and KB.
TCP Stream Multiplexing
frp supports tcp stream multiplexing since v0.10.0 like HTTP2 Multiplexing, in which case all logic connections to the same frpc are multiplexed into the same TCP connection.
You can disable this feature by modify frps.ini and frpc.ini:
# frps.ini and frpc.ini, must be same
[common]
tcp_mux = falseSupport KCP Protocol
KCP is a fast and reliable protocol that can achieve the transmission effect of a reduction of the average latency by 30% to 40% and reduction of the maximum delay by a factor of three, at the cost of 10% to 20% more bandwidth wasted than TCP.
KCP mode uses UDP as the underlying transport. Using KCP in frp:
- Enable KCP in frps:
# frps.ini
[common]
bind_port = 7000
# Specify a UDP port for KCP.
kcp_bind_port = 7000The kcp_bind_port number can be the same number as bind_port, since bind_port field specifies a TCP port.
- Configure
frpc.inito use KCP to connect to frps:
# frpc.ini
[common]
server_addr = x.x.x.x
# Same as the 'kcp_bind_port' in frps.ini
server_port = 7000
protocol = kcpConnection Pooling
By default, frps creates a new frpc connection to the backend service upon a user request. With connection pooling, frps keeps a certain number of pre-established connections, reducing the time needed to establish a connection.
This feature is suitable for a large number of short connections.
- Configure the limit of pool count each proxy can use in
frps.ini:
# frps.ini
[common]
max_pool_count = 5- Enable and specify the number of connection pool:
# frpc.ini
[common]
pool_count = 1Load balancing
Load balancing is supported by group.
This feature is only available for types tcp and http now.
# frpc.ini
[test1]
type = tcp
local_port = 8080
remote_port = 80
group = web
group_key = 123
[test2]
type = tcp
local_port = 8081
remote_port = 80
group = web
group_key = 123group_key is used for authentication.
Connections to port 80 will be dispatched to proxies in the same group randomly.
For type tcp, remote_port in the same group should be the same.
For type http, custom_domains, subdomain, locations should be the same.
Service Health Check
Health check feature can help you achieve high availability with load balancing.
Add health_check_type = tcp or health_check_type = http to enable health check.
With health check type tcp, the service port will be pinged (TCPing):
# frpc.ini
[test1]
type = tcp
local_port = 22
remote_port = 6000
# Enable TCP health check
health_check_type = tcp
# TCPing timeout seconds
health_check_timeout_s = 3
# If health check failed 3 times in a row, the proxy will be removed from frps
health_check_max_failed = 3
# A health check every 10 seconds
health_check_interval_s = 10With health check type http, an HTTP request will be sent to the service and an HTTP 2xx OK response is expected:
# frpc.ini
[web]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = test.example.com
# Enable HTTP health check
health_check_type = http
# frpc will send a GET request to '/status'
# and expect an HTTP 2xx OK response
health_check_url = /status
health_check_timeout_s = 3
health_check_max_failed = 3
health_check_interval_s = 10Rewriting the HTTP Host Header
By default frp does not modify the tunneled HTTP requests at all as it's a byte-for-byte copy.
However, speaking of web servers and HTTP requests, your web server might rely on the Host HTTP header to determine the website to be accessed. frp can rewrite the Host header when forwarding the HTTP requests, with the host_header_rewrite field:
# frpc.ini
[web]
type = http
local_port = 80
custom_domains = test.example.com
host_header_rewrite = dev.example.comThe HTTP request will have the the Host header rewritten to Host: dev.example.com when it reaches the actual web server, although the request from the browser probably has Host: test.example.com.
Setting other HTTP Headers
Similar to Host, You can override other HTTP request headers with proxy type http.
# frpc.ini
[web]
type = http
local_port = 80
custom_domains = test.example.com
host_header_rewrite = dev.example.com
header_X-From-Where = frpNote that parameter(s) prefixed with header_ will be added to HTTP request headers.
In this example, it will set header X-From-Where: frp in the HTTP request.
Get Real IP
HTTP X-Forwarded-For
This feature is for http proxy only.
You can get user's real IP from HTTP request headers X-Forwarded-For and X-Real-IP.
Proxy Protocol
frp supports Proxy Protocol to send user's real IP to local services. It support all types except UDP.
Here is an example for https service:
# frpc.ini
[web]
type = https
local_port = 443
custom_domains = test.example.com
# now v1 and v2 are supported
proxy_protocol_version = v2You 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
Anyone who can guess your tunnel URL can access your local web server unless you protect it with a password.
This enforces HTTP Basic Auth on all requests with the username and password specified in frpc's configure file.
It can only be enabled when proxy type is http.
# frpc.ini
[web]
type = http
local_port = 80
custom_domains = test.example.com
http_user = abc
http_pwd = abcVisit http://test.example.com in the browser and now you are prompted to enter the username and password.
Custom Subdomain Names
It is convenient to use subdomain configure for http and https types when many people share one frps server.
# frps.ini
subdomain_host = frps.comResolve *.frps.com to the frps server's IP. This is usually called a Wildcard DNS record.
# frpc.ini
[web]
type = http
local_port = 80
subdomain = testNow 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
frp supports forwarding HTTP requests to different backend web services by url routing.
locations specifies the prefix of URL used for routing. frps first searches for the most specific prefix location given by literal strings regardless of the listed order.
# frpc.ini
[web01]
type = http
local_port = 80
custom_domains = web.example.com
locations = /
[web02]
type = http
local_port = 81
custom_domains = web.example.com
locations = /news,/aboutHTTP requests with URL prefix /news or /about will be forwarded to web02 and other requests to web01.
TCP Port 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.
The only supported TCP port multiplexing method available at the moment is httpconnect - HTTP CONNECT tunnel.
When setting tcpmux_httpconnect_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 type = tcpmux proxies, when multiplexer = httpconnect.
For example:
# frps.ini
[common]
bind_port = 7000
tcpmux_httpconnect_port = 1337# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[proxy1]
type = tcpmux
multiplexer = httpconnect
custom_domains = test1
[proxy2]
type = tcpmux
multiplexer = httpconnect
custom_domains = test2In 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 routed 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.
It only works when protocol is tcp.
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
http_proxy = http://user:[email protected]:8080Range ports mapping
Proxy with names that start with range: will support mapping range ports.
# frpc.ini
[range:test_tcp]
type = tcp
local_ip = 127.0.0.1
local_port = 6000-6006,6007
remote_port = 6000-6006,6007frpc will generate 8 proxies like test_tcp_0, test_tcp_1, ..., test_tcp_7.
Client Plugins
frpc only forwards requests to local TCP or UDP ports by default.
Plugins are used for providing rich features. There are built-in plugins such as unix_domain_socket, http_proxy, socks5, static_file and you can see .
Find more plugins in and consider sending a Pull Request to dev branch.
SOCIAL SHARE CARD GENERATOR