frp 内网穿透 + Apache 反向代理

>参考：
>https://github.com/fatedier/frp
>https://github.com/CNFlyCat/UsefulTutorials/blob/master/Frp%E5%86%85%E7%BD%91%E7%A9%BF%E9%80%8F%E6%90%AD%E5%BB%BA%E6%95%99%E5%AD%A6/README.md

## Server
**下载 [frp](https://github.com/fatedier/frp/releases)**
```bash
cd /usr/local
mkdir -p frp
wget https://github.com/fatedier/frp/releases/download/v0.61.1/frp_0.61.1_linux_amd64.tar.gz
tar -xvzf frp_0.61.1_linux_amd64.tar.gz
cp frp_0.61.1_linux_amd64/* ./frp
```

**frp 服务端配置**
```bash
cd /usr/local/frp
sudo nano ./frps.toml
```

```toml
# /usr/local/frp/frps.toml
bindAddr = "0.0.0.0"
bindPort = 7000

# 内网 HTTP 代理穿透
vhostHTTPPort = 8081
vhostHTTPSPort = 8443

subDomainHost = "liteink.cn"

# frp server dashboard
webServer.addr = "0.0.0.0"
webServer.port = 7500
webServer.user = "admin"
webServer.password = "O0P-o0p-"

auth.method = "token"
auth.token = "3bd4b2b8-a817-47bc-ad28-1af4f8fb8ace"
```

**启动服务端 frp**
Option 1：单次启动
```bash
./frps -c ./frps.toml
```
Option 2：使用systemd, [参考](https://gofrp.org/zh-cn/docs/setup/systemd/)
```bash
sudo nano /etc/systemd/system/frps.service
```

```service
# /etc/systemd/system/frps.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target

[Service]
Type = simple
ExecStart = /usr/local/frp/frps -c /usr/local/frp/frps.toml

[Install]
WantedBy = multi-user.target
```

```bash
# 启动frp
sudo systemctl start frps
# 停止frp
sudo systemctl stop frps
# 重启frp
sudo systemctl restart frps
# 查看frp状态
sudo systemctl status frps

# 设置 frps 开机自启动
sudo systemctl enable frps
```

## Client
**下载 Windows frp 并配置 frpc.toml**
```toml
# D:\apps\frp>frpc.toml
serverAddr = "8.219.173.222"
serverPort = 7000

transport.protocol = "tcp"
auth.method = "token"
auth.token = "3bd4b2b8-a817-47bc-ad28-1af4f8fb8ace"

# frp client dashboard
webServer.addr = "127.0.0.1"
webServer.port = 7400
webServer.user = "admin"
webServer.password = "O0P-o0p-"

# 通过 cat.liteink.com 访问
# 需要添加解析 cat.liteink.com 指向服务器公网ip
# 如果 vhostHTTPPort 不是80, 而是例如8080，需要指定端口 cat.liteink.com:8080
# 也可以 Apache/Nginx 反向代理，将 cat.liteink.com 的 80 端口流量转发到 http://127.0.0.1:8080
[[proxies]]
name = "cat"
type = "http"
localIP = "127.0.0.1"
# 本地服务端口
localPort = 8000
subdomain = "cat"

# ip:port 直连, liteink.com:remotePort
[[proxies]]
name = "cat1"
type = "tcp"
localIP = "127.0.0.1"
# 本地服务端口
localPort = 8001
# 服务器监听端口，与 localPort 一致
remotePort = 8001
```

**启动客户端 frp**
```cmd
D:\apps\frp> frpc.exe -c frpc.toml
```

## Apache 反向代理

```conf
# /etc/apache2/sites-available/webdav.conf
<VirtualHost *:80>

    Alias /webdav /var/www/webdav
    <Directory /var/www/webdav>
        DAV On
        AuthType Basic
        AuthName "WebDAV"
        AuthUserFile /etc/apache2/webdav.passwd
        Require valid-user
    </Directory>

</VirtualHost>


<VirtualHost *:80>

    ServerName cat.liteink.cn

    ProxyRequests Off
    ProxyPreserveHost On

    proxyPass / http://127.0.0.1:8081/
    ProxyPassReverse / http://127.0.0.1:8081/

    ProxyPass /websocket ws://127.0.0.1:8081/websocket
    ProxyPassReverse /websocket ws://127.0.0.1:8081/websocket

</VirtualHost>
```

```bash
sudo systemctl restart apache2
sudo systemctl status apache2
```

id: 82855b756246477a94b75e9f14911929
parent_id: e80f9816880d4bddb66e3437b0e43e8f
created_time: 2026-01-27T08:16:36.146Z
updated_time: 2026-01-31T18:54:07.321Z
is_conflict: 0
latitude: 34.34157500
longitude: 108.93977000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin-desktop
source_application: net.cozic.joplin-desktop
application_data: 
order: 442376475432
user_created_time: 2026-01-27T08:16:36.146Z
user_updated_time: 2026-01-31T18:54:07.321Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
master_key_id: 
user_data: 
deleted_time: 0
type_: 1