frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet. As of now, it supports tcp & udp, as well as http and https protocols, where requests can be forwarded to internal services by domain name.
Now it also try to support p2p connect.
- Status
- Architecture
- Example Usage
- Features
- Configuration File
- Configuration file template
- Dashboard
- Authentication
- Encryption and Compression
- Hot-Reload frpc configuration
- Get proxy status from client
- Port White List
- Port Reuse
- TCP Stream Multiplexing
- Support KCP Protocol
- Connection Pool
- Load balancing
- Health Check
- Rewriting the Host Header
- Set Headers In HTTP Request
- Get Real IP
- Password protecting your web service
- Custom subdomain names
- URL routing
- Connect frps by HTTP PROXY
- Range ports mapping
- Plugin
- Development Plan
- Contributing
- Donation
frp is under development and you can try it with latest release version. Master branch for releasing stable version when dev branch for developing.
We may change any protocol and can't promise backward compatible. Please check the release log when upgrading.
Firstly, download the latest programs from Release page according to your os and arch.
Put frps and frps.ini to your server with public IP.
Put frpc and frpc.ini to your server in LAN.
- Modify frps.ini:
# frps.ini
[common]
bind_port = 7000
- Start frps:
./frps -c ./frps.ini
- Modify frpc.ini,
server_addr
is your frps's server IP:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
- Start frpc:
./frpc -c ./frpc.ini
- Connect to server in LAN by ssh assuming that username is test:
ssh -oPort=6000 test@x.x.x.x
Sometimes we want to expose a local web service behind a NAT network to others for testing with your own domain name and unfortunately we can't resolve a domain name to a local ip.
However, we can expose a http or https service using frp.
- Modify frps.ini, configure http port 8080:
# frps.ini
[common]
bind_port = 7000
vhost_http_port = 8080
- Start frps:
./frps -c ./frps.ini
- Modify frpc.ini and set remote frps server's IP as x.x.x.x. The
local_port
is the port of your web service:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[web]
type = http
local_port = 80
custom_domains = www.yourdomain.com
- Start frpc:
./frpc -c ./frpc.ini
-
Resolve A record of
www.yourdomain.com
to IPx.x.x.x
or CNAME record to your origin domain. -
Now visit your local web service using url
http://www.yourdomain.com:8080
.
- Modify frps.ini:
# frps.ini
[common]
bind_port = 7000
- Start frps:
./frps -c ./frps.ini
- Modify frpc.ini, set remote frps's server IP as x.x.x.x, forward dns query request to google dns server
8.8.8.8:53
:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[dns]
type = udp
local_ip = 8.8.8.8
local_port = 53
remote_port = 6000
- Start frpc:
./frpc -c ./frpc.ini
- Send dns query request by dig:
dig @x.x.x.x -p 6000 www.google.com
Using tcp port to connect unix domain socket like docker daemon.
Configure frps same as above.
- Start frpc with configurations:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[unix_domain_socket]
type = tcp
remote_port = 6000
plugin = unix_domain_socket
plugin_unix_path = /var/run/docker.sock
- Get docker version by curl command:
curl http://x.x.x.x:6000/version
A simple way to visit files in the LAN.
Configure frps same as above.
- Start frpc with configurations:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[test_static_file]
type = tcp
remote_port = 6000
plugin = static_file
plugin_local_path = /tmp/file
plugin_strip_prefix = static
plugin_http_user = abc
plugin_http_passwd = abc
- Visit
http://x.x.x.x:6000/static/
by your browser, set correct user and password, so you can see files in/tmp/file
.
For some services, if expose them to the public network directly will be a security risk.
stcp(secret tcp) help you create a proxy avoiding any one can access it.
Configure frps same as above.
- Start frpc, forward ssh port and
remote_port
is useless:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[secret_ssh]
type = stcp
sk = abcdefg
local_ip = 127.0.0.1
local_port = 22
- Start another frpc in which you want to connect this ssh server:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[secret_ssh_visitor]
type = stcp
role = visitor
server_name = secret_ssh
sk = abcdefg
bind_addr = 127.0.0.1
bind_port = 6000
- Connect to server in LAN by ssh assuming that username is test:
ssh -oPort=6000 test@127.0.0.1
xtcp is designed for transmitting a large amount of data directly between two client.
Now it can't penetrate all types of NAT devices. You can try stcp if xtcp doesn't work.
- Configure a udp port for xtcp:
bind_udp_port = 7001
- Start frpc, forward ssh port and
remote_port
is useless:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[p2p_ssh]
type = xtcp
sk = abcdefg
local_ip = 127.0.0.1
local_port = 22
- Start another frpc in which you want to connect this ssh server:
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
[p2p_ssh_visitor]
type = xtcp
role = visitor
server_name = p2p_ssh
sk = abcdefg
bind_addr = 127.0.0.1
bind_port = 6000
- Connect to server in LAN by ssh assuming that username is test:
ssh -oPort=6000 test@127.0.0.1
You can find features which this document not metioned from full example configuration files.
Configuration file tempalte can be rendered using os environments. Template uses Go's standard format.
# frpc.ini
[common]
server_addr = {{ .Envs.FRP_SERVER_ADDR }}
server_port = 7000
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = {{ .Envs.FRP_SSH_REMOTE_PORT }}
Start frpc program:
export FRP_SERVER_ADDR="x.x.x.x"
export FRP_SSH_REMOTE_PORT="6000"
./frpc -c ./frpc.ini
frpc will auto render configuration file template using os environments.
All environments has prefix .Envs
.
Check frp's status and proxies's statistics information by Dashboard.
Configure a port for dashboard 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 = admin
Then visit http://[server_addr]:7500
to see dashboard, default username and password are both admin
.
token
in frps.ini and frpc.ini should be same.
Defalut value is false, you could decide if the proxy will use encryption or compression:
# frpc.ini
[ssh]
type = tcp
local_port = 22
remote_port = 6000
use_encryption = true
use_compression = true