index.html

Local Service Tunneling with FRP and Caddy

Word count: 229Reading time: 1 min
2019/04/14 Share

Goal

Setup a WebDAV file server and a local webpage with Caddy, then expose the services to the Internet using FRP.

Localhost

Caddy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# /etc/caddy/config
http://:80/webdav/ {
log stdout
basicauth / Apocalypse 4W9yaFeC8szfsJGF
basicauth / Zaychik aKQG96BjmQ9Vq8AB
webdav / {
scope /mnt/share/
Apocalypse:
modify true
Zaychik:
modify false
}
}

http://:80/web_dev/ {
log stdout
basicauth / Kaslana 9EuCXSvwdCnsPS3Q
proxy / localhost:19999 {
}
}

FRP Client

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# /etc/frp/frpc.ini
[common]
server_addr = foo.com
server_port = 7000
login_fail_exit = true
protocol = tcp
privilege_token = mZBhe5CaxjxTGdNL

[Web]
type = tcp
local_ip = 127.0.0.1
local_port = 80
remote_port = 8080
use_encryption = true
use_compression = true

Proxy Server

Caddy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# /etc/caddy/config
http://foo.com:80, https://foo.com:443 {
log stdout
redir 301 {
if {scheme} is http
/ https://{host}{uri}
}
tls /path_to_cert/foo.com/fullchain /path_to_cert/foo.com/key
root /wwwroot/
index index.html

proxy /frp/ http://127.0.0.1:8080 {
without /frp # strip '/frp' from the URI
transparent
}
}

FRP Server

1
2
3
4
5
6
7
8
9
# /etc/frp/frps.ini
[common]
bind_port = 7000
kcp_bind_port = 7000
bind_udp_port = 7001
dashboard_port = 7500
dashboard_user = Rossweisse
dashboard_pwd = tNyexbhGKY8pzHzU
privilege_token = mZBhe5CaxjxTGdNL

Tips

To add a WebDAV network location in Windows, the directory format must be “https://foo.com/frp/webdav/sub_dir". The trailing slash at the end must NOT be added, and at least one sub directory should be specified. “https://foo.com/frp/webdav/" and “https://foo.com/frp/webdav" will NOT work. Curse you stupid Windows!


EOF

CATALOG
  1. 1. Goal
  2. 2. Localhost
    1. 2.1. Caddy
    2. 2.2. FRP Client
  3. 3. Proxy Server
    1. 3.1. Caddy
    2. 3.2. FRP Server
  4. 4. Tips