域名反代管理工具

使用Caddy解析到机器端口

官方教程

1
2
3
4
5
6
7
# 安装caddy 
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -
echo "deb [trusted=yes] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" | sudo tee /etc/apt/sources.list.d/caddy-stable.list

sudo apt update
sudo apt install caddy
caddy version
  1. Caddy可以采用Caddyfile或者json配置文件两种方式运行。Caddyfile可较为方便自行构建配置信息,json则主要用于自动配置。

Nginx Proxy Manager

Nginx Proxy Manager是一款服务器管理工具,可进行域名绑定、反向代理、重定向、端口转发和证书管理。

创建模板文件 docker-compose.yml

1
2
3
4
5
6
7
8
9
mkdir nginx_proxy_manger
cd nginx_proxy_manger
touch docker-compose.yml

nano docker-compose.yml # 按下面提供的模板进行修改

# 构建并后台运行容器
docker-compose up -d

模板内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
version: '3.8'
services:
app:
# image: 'jc21/nginx-proxy-manager:latest' # English
image: 'chishin/nginx-proxy-manager-zh' # Chinese
restart: unless-stopped
ports:
# These ports are in format <host-port>:<container-port>
- '81:81' # Admin Web Port
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
# Add any other Stream port you want to expose
# - '21:21' # FTP

# Uncomment the next line if you uncomment anything in the section
# environment:
# Uncomment this if you want to change the location of
# the SQLite DB file within the container
# DB_SQLITE_FILE: "/data/database.sqlite"

# Uncomment this if IPv6 is not enabled on your host
# DISABLE_IPV6: 'true'

volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt

默认登录用户名和密码

Email: admin@example.com
Password: changeme

Apache2

1
2
3
4
5
6
7
8
9
10
apt update 
apt install apache2

systemctl start apache2 # 启动Apache2服务
systemctl stop apache2 # 停止Apache2服务
systemctl restart apaceh2 # 重启Apache2服务

sudo a2ensite example.com.conf # 启用虚拟主机
sudo a2dissite example.com.conf # 禁用虚拟主机