Install frp on Ubuntu 18.04

In WeChat development, a server with a domain name is required as a trusted server for the backend. This brings a lot of trouble to development and debugging, and the solution is to use intranet penetration tools so that development machines in the intranet can also have externally accessible domain names. Of course, there are already some intranet penetration services that are either free or paid online and can be used directly. This article describes the use of the open source project frp to build a direct intranet penetration service.

In order to complete the actual list of this article, you need to have a server that can be accessed on the Internet, which can be purchased from Amazon, Digitalocean or other cloud service providers, and the price is not expensive. If you need to use your own domain name for intranet penetration, you can also purchase another domain name and complete the necessary certifications.For the convenience of later description, assume that:

Server IP is: 173.178.10.45
Domain name is: examples.net
Server OS: ubuntu 18.04
Client OS: Windows 10

Download frp Server

Download frp from Offical Website, Choose frp_0.33.0_linux_amd64.tar.gz。

You can also execute the following command on ubuntu terminal:

1
wget https://github.com/fatedier/frp/releases/download/v0.33.0/frp_0.33.0_linux_amd64.tar.gz

After the download is complete, unzip it and you can see that the directory contains the executor and configuration sample files of the server side (frps) and the client (frpc). To avoid confusion later, you can delete all frpc files.

Setup frp Server

  1. Copy frps into /usr/bin
1
sudo cp frps /usr/bin
  1. Create a folder, name it to /etc/frp
1
sudo mkdir /etc/frp
  1. Copy frps_full.ini file into /etc/frp and remame it to frps.ini
1
sudo cp frps_full.ini /etc/frp/frps.ini
  1. Create a folder, and name it to /var/frp, it will be used to store the log.
1
sudo mkdir /var/frp
  1. Base your need,edit the configuration file: /etc/frp/frps.ini

In this article, we only modify the following line:

1
2
3
4
5
6
7
8
bind_port = 1500
vhost_http_port = 1580
vhost_https_port = 1543
dashboard_port = 1300
dashboard_user = admin
dashboard_pwd = 123456
log_file = /var/frp/frps.log
token = abcd1234

bind_port - The port used to communicate with the client is consistent with the client’s settings
vhost_http_port - The http port of frps server
vhost_https_port - The https port of frps server
dashboard_port - frps server has a web admin console,it’s the port of admin console
dashboard_user - The user of admin conosle
dashboard_pwd - The password of amdin user
token - The token for the connections between frps and frpc

Note: You need to modify the above configuration information according to the situation of your environment

And comment out the last two plugins

1
2
3
4
5
6
7
8
9
# [plugin.user-manager]
# addr = 127.0.0.1:9000
# path = /handler
# ops = Login

# [plugin.port-manager]
# addr = 127.0.0.1:9001
# path = /handler
# ops = NewProxy
  1. Copy the frps.service file in the systemd directory in the installation package to /var/systemd/system:
1
sudo cp systemd/frps.service /var/systemd/system
  1. Startup frps Server
1
sudo systemctl start frps

You can use the status subcommand to check the startup and operation of the frps service

1
sudo systemctl status frps

If there are no problems with the installation, you should see output similar to the following

1
2
3
4
5
6
7
8
9
10
11
● frps.service - Frp Server Service
Loaded: loaded (/lib/systemd/system/frps.service; enabled; vendor preset: ena
Active: active (running) since Wed 2020-06-10 20:21:45 CST; 19h ago
Main PID: 32475 (frps)
Tasks: 5
Memory: 6.7M
CPU: 2.461s
CGroup: /system.slice/frps.service
└─32475 /usr/bin/frps -c /etc/frp/frps.ini

Jun 10 20:21:45 VM-0-4-ubuntu systemd[1]: Started Frp Server Service.
  1. Set boot startup
1
sudo systemctl enable frps

Install frp client

Because the client is running on Windows 10, download the file from the official website frp_0.33.0_windows_amd64.zip

After extracting, you can see the executable file of frpc, which is the client program.

Create a new file (text file) for a frpc .ini

The following configuration information:

1
2
3
4
5
6
7
8
9
10
11
[common]
server_addr = 173.178.10.45
server_port = 1500

# for authentication
token = abcd1234

[web]
type = http
local_port = 8080
custom_domains = api.examples.net

where server_port and server-side configuration items bind_port for, the token corresponds to the server-side token.

Now, you can then start the frp client, executing:

1
frpc.exe -c frpc.ini

After startup, the development environment on the startup machine, such as the Spring Boot project in IDEA, runs on port 8080 by default.

Set DNS Service

In the DNS management interface, set up an A record for DNS, which in the case is set to

1
api.examples.net  173.178.10.45

Once set up, you can access it in a browser

1
http://api.examples.net:1500

Set up multiple web services

Only modifications need to be made in the client’s configuration:

1
2
3
4
5
6
7
8
9
[web]
type = http
local_port = 8080
custom_domains = api.examples.net

[web2]
type = http
local_port = 4000
custom_domains = web.examples.net

Note: Custom_domains need to be different

本文标题:Install frp on Ubuntu 18.04

文章作者:Morning Star

发布时间:2020年06月11日 - 18:06

最后更新:2022年01月05日 - 17:01

原始链接:https://www.mls-tech.info/linux/ubuntu-18-frp-en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。