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 and UDP, as well as HTTP and HTTPS protocols, where requests can be forwarded to internal services by domain name.

Video Tutorial (Chinese)

"司波图": https://www.youtube.com/watch?v=rj8vhniGrwA

Useful Links

GitHub Repository: https://github.com/fatedier/frp

GitHub Release Package: https://github.com/fatedier/frp/releases

Instruction

  1. Download the released package in GitHub (You need to choose the one that fits your architecture)

    For example:

    wget https://github.com/fatedier/frp/releases/download/v0.38.0/frp_0.38.0_linux_amd64.tar.gz
  2. Unzip the downloaded file

    For example:

    tar -zxvf frp_0.38.0_linux_amd64.tar.gz
  3. Change the folder name, then open the folder
  4. The folder is included in both server and client configuration files. frpc.ini is the client configuration file, and frps.ini is the server configuration file. The Frp server should be deployed at a VPS with a public IP address (Ex. Google Cloud, Tencent Cloud, Alibaba Cloud, etc.). The Frp client should be deployed in the local network.

    frpc_full.ini and frps_full.ini is sample configuration provided by the Frp developer. You can try many of the new features through them.

Server

  1. frps.ini Configuration File Sample

    [common]
    #A port number used to accept client connection
    bind_port = 7000
    #Password required for connection
    token = password
  2. Run the Frp script (Single time run only for testing, Will be terminated after the terminal closed)

    ./frps -c frps.ini
  3. Be careful about your VPS firewall setting. It could be either a software firewall (iptables, ufw, firewall) or safety features set by your service provider. You need to open the corresponding port above. Above, we use port 7000. Make sure you open it.
  4. Using Systemctl to keep the program running after disconnecting the SSH.
  5. Create a new file named frpc.service

    nano /lib/systemd/system/frps.service
  6. Enter the script below (Note: ExecStart= should be your own Frp script path. DO NOT Just Copy and Paste on that line)

    [Unit]
    Description=fraps service
    After=network.target syslog.target
    Wants=network.target
    
    [Service]
    Type=simple
    ExecStart=/root/frp/frps -c /root/frp/frps.ini
    
    [Install]
    WantedBy=multi-user.target
  7. Manage Script

    # Set an automated start after the machine boots up
    systemctl enable frps
    
    # Start service
    systemctl start frps
    
    # Stop the service
    systemctl stop frps
    
    # Restart the service
    systemctl restart frps
    
    # Check service status
    systemctl status frps

Client

  1. frpc.ini Configuration File Sample

    [common]
    #The public address of your Frps server
    server_addr = 127.0.0.1
    #The port you set in Frps server
    server_port = 7000
    #The password you set in Frps server
    token = password
    
    [ssh]
    #Connection Type (Please refer to frpc_full.ini file to select an appropriate one)
    type = tcp
    #The intranet IP of the machine that needs to be mapped
    #(127.0.0.1 refers to the localhost of the machine,
    #and the IP of other machines can be 192.168.1.1, for example)
    local_ip = 22
    #An remote port used to access the local machine you mapped
    remote_port = 7001
  2. Run the Frp script (Single time run only for testing, Will be terminated after the terminal closed)

    ./frpc -c frpc.ini
  3. Using Systemctl to keep the program running after disconnecting the SSH.
  4. Create a new file named frpc.service

    nano /lib/systemd/system/frpc.service
  5. Enter the script below (Note: ExecStart= should be your own Frp script path. DO NOT Just Copy and Paste on that line)

    [Unit]
    Description=frapc service
    After=network.target syslog.target
    Wants=network.target
    
    [Service]
    Type=simple
    ExecStart=/root/frp/frpc -c /root/frp/frpc.ini
    
    [Install]
    WantedBy=multi-user.target
  6. Manage Script

    # Set an automated start after the machine boots up
    systemctl enable frpc
    
    # Start service
    systemctl start frpc
    
    # Stop the service
    systemctl stop frpc
    
    # Restart the service
    systemctl restart frpc
    
    # Check service status
    systemctl status frpc
TOC