文章

异地代理服务器搭建

异地代理服务器搭建

一个客户因为业务需要,需要在A区使用B区的ip访问某个系统,很简单的场景,使用一个代理服务器即可完成。这里可以使用电脑的虚拟机,还可以使用一台小型的Linux服务器,二者都是需要24小时开机,所以我就买了一个移动魔百盒刷入了armlinux作为服务器,2G+16G的配置绰绰有余。

image-20240822100054684网络问题由于ipv4公网很难申请,所以索性直接使用ipv6,好在A区B区都已经支持了ipv6。

XUI安装

使用xui作为代理服务器的核心,可视化面板操作起来很方便。

官网:https://github.com/vaxilu/x-ui

一键安装脚本:

1
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

image-20240822100246818

DDNS安装

这里使用ddns-go,简单易操作。

官网地址:https://github.com/jeessy2/ddns-go

下载了release之后执行下面将其安装成服务:

1
sudo ./ddns-go -s install

注意要下载文件名形如frp_0.60.0_linux_arm的版本,不要下成freebsd的版本了。

image-20240822100200986

FRP安装

配置一个内网穿透避免失去控制权。

官网:https://github.com/fatedier/frp

下载可执行文件之后放在一个文件夹后,编写服务文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
[Unit]
Description=FRP Client Service
After=network.target

[Service]
Type=simple
User=nobody
ExecStart=/home/frpc/frp_0.60.0_linux_arm/frpc -c /home/frpc/frp_0.60.0_linux_arm/frpc.ini
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

编写frpc配置文件:

1
2
3
4
5
6
7
8
9
10
11
12
[common]
server_addr=example.com
server_port=5005
token=666

[ssh2]
type=tcp
local_ip=127.0.0.1
local_port=22
use_encryption=false
use_compression=true
remote_port=2223
本文由作者按照 CC BY 4.0 进行授权