同服务器安装
同服务器安装意味着您将在与 Remnawave 面板相同的服务器上安装订阅页面。
步骤 1 - 准备 .env 文件
编辑 /opt/remnawave/.env 文件,将 SUB_PUBLIC_DOMAIN 更改为您的订阅页面域名。
cd /opt/remnawave && nano .env
将 SUB_PUBLIC_DOMAIN 更改为您的订阅页面域名。域名必须不含 http 或 https。
SUB_PUBLIC_DOMAIN=subscription.domain.com
不要忘记重启 Remnawave 面板容器:
cd /opt/remnawave && docker compose down remnawave && docker compose up -d && docker compose logs -f
步骤 2 - 创建 docker-compose.yml 文件
mkdir -p /opt/remnawave/subscription && cd /opt/remnawave/subscription && nano docker-compose.yml
services:
remnawave-subscription-page:
image: remnawave/subscription-page:latest
container_name: remnawave-subscription-page
hostname: remnawave-subscription-page
restart: always
env_file:
- .env
ports:
- '127.0.0.1:3010:3010'
networks:
- remnawave-network
networks:
remnawave-network:
driver: bridge
external: true
现在创建 .env 文件:
mkdir -p /opt/remnawave/subscription && cd /opt/remnawave/subscription && nano .env
在 Remnawave 仪表板中创建 API 令牌。Remnawave 设置 → API 令牌。
将以下内容粘贴到 .env 文件中:
APP_PORT=3010
REMNAWAVE_PANEL_URL=http://remnawave:3000
REMNAWAVE_API_TOKEN=API_TOKEN_FROM_REMNAWAVE
完整 .env 文件参考
APP_PORT=3010
### Remnawave 面板 URL,可以是 http://remnawave:3000 或 https://panel.example.com
REMNAWAVE_PANEL_URL=http://remnawave:3000
REMNAWAVE_API_TOKEN=API_TOKEN_FROM_REMNAWAVE
# 在自定义根路径提供服务,例如,此值可以是:CUSTOM_SUB_PREFIX=sub
# 开头/结尾不要放 /
CUSTOM_SUB_PREFIX=
# 支持 Marzban 链接
MARZBAN_LEGACY_LINK_ENABLED=false
MARZBAN_LEGACY_SECRET_KEY=
# 如果您使用"带安全的 Caddy"插件,可以在此处放置 X-Api-Key,它将应用于对 Remnawave 面板的请求。
CADDY_AUTH_API_TOKEN=
步骤 3 - 启动容器
docker compose up -d && docker compose logs -f
步骤 4 - 配置反向代理
Remnawave 及其组件不支持在子路径上提供服务。(例如 location /subscription {)
它必须在域或子域的根路径上提供服务。
对于自定义路径,您可以使用 CUSTOM_SUB_PREFIX 参数。
Caddy
Caddy 配置
如果您已经配置了 Caddy,只需在 Caddyfile 中添加新的站点块即可。
cd /opt/remnawave/caddy && nano Caddyfile
请将 SUBSCRIPTION_PAGE_DOMAIN 替换为您的域名。
查看下面的配置,注意绿色高亮行。
不要完全替换现有配置,只需在现有 Caddyfile 中添加新的站点块。
在配置文件末尾添加新的站点块。
注意绿色行,这些是您需要添加的行。
https://REPLACE_WITH_YOUR_DOMAIN {
reverse_proxy * http://remnawave:3000
}
https://SUBSCRIPTION_PAGE_DOMAIN {
reverse_proxy * http://remnawave-subscription-page:3010
}
现在需要重启 Caddy 容器。
docker compose down && docker compose up -d && docker compose logs -f
Nginx
Nginx 配置
如果您已经配置了 Nginx,只需在配置文件中添加新的 location 块即可。
为订阅页面域名颁发证书:
acme.sh --issue --standalone -d 'SUBSCRIPTION_PAGE_DOMAIN' --key-file /opt/remnawave/nginx/subdomain_privkey.key --fullchain-file /opt/remnawave/nginx/subdomain_fullchain.pem --alpn --tlsport 8443 --reloadcmd "docker exec remnawave-nginx nginx -s reload"
打开 Nginx 配置文件:
cd /opt/remnawave/nginx && nano nginx.conf
请将 SUBSCRIPTION_PAGE_DOMAIN 替换为您的订阅页面域名。
不要完全替换现有配置,只需在现有配置文件中添加新的 location 块。
在配置文件顶部添加新的 upstream 块。
注意绿色行,这些是您需要添加的行。
upstream remnawave {
server remnawave:3000;
}
upstream remnawave-subscription-page {
server remnawave-subscription-page:3010;
}
现在在配置文件底部添加新的 server 块。
server {
server_name SUBSCRIPTION_PAGE_DOMAIN;
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
location / {
proxy_http_version 1.1;
proxy_pass http://remnawave-subscription-page;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# SSL 配置(Mozilla 中级指南)
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_certificate "/etc/nginx/ssl/subdomain_fullchain.pem";
ssl_certificate_key "/etc/nginx/ssl/subdomain_privkey.key";
ssl_trusted_certificate "/etc/nginx/ssl/subdomain_fullchain.pem";
ssl_stapling on;
ssl_stapling_verify on;
resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
resolver_timeout 2s;
# Gzip 压缩
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rdf+xml
application/rss+xml
application/xhtml+xml
application/xml
font/eot
font/otf
font/ttf
image/svg+xml
text/css
text/javascript
text/plain
text/xml;
}
现在修改 Nginx 的 docker-compose.yml 以挂载新的证书文件。
cd /opt/remnawave/nginx && nano docker-compose.yml
services:
remnawave-nginx:
image: nginx:1.28
container_name: remnawave-nginx
hostname: remnawave-nginx
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./fullchain.pem:/etc/nginx/ssl/fullchain.pem:ro
- ./privkey.key:/etc/nginx/ssl/privkey.key:ro
- ./subdomain_fullchain.pem:/etc/nginx/ssl/subdomain_fullchain.pem:ro
- ./subdomain_privkey.key:/etc/nginx/ssl/subdomain_privkey.key:ro
restart: always
ports:
- '0.0.0.0:443:443'
networks:
- remnawave-network
networks:
remnawave-network:
name: remnawave-network
driver: bridge
external: true
现在需要重启 Nginx 容器。
docker compose down && docker compose up -d && docker compose logs -f
Traefik
Traefik 配置
如果您已经配置了 Traefik,需要在 /opt/remnawave/traefik/config 目录中创建名为 remnawave-sub-page.yml 的新动态配置文件。
cd /opt/remnawave/traefik/config && nano remnawave-sub-page.yml
粘贴以下配置。
请将 SUBSCRIPTION_PAGE_DOMAIN 替换为您的订阅页面域名。
查看下面的配置,注意黄色高亮行。
http:
routers:
remnawave-sub-page:
rule: "Host(`SUBSCRIPTION_PAGE_DOMAIN`)"
entrypoints:
- https
tls:
certResolver: letsencrypt
middlewares:
- remnawave-sub-page-https-redirect
service: remnawave-sub-page
middlewares:
remnawave-sub-page-https-redirect:
redirectScheme:
scheme: https
services:
remnawave-sub-page:
loadBalancer:
servers:
- url: "http://remnawave-subscription-page:3010"
步骤 5 - 使用
订阅页面将在 https://subdomain.panel.com/<shortUuid> 处可用。
配置订阅页面(可选)
您可以在 Remnawave 仪表板的子页面构建器中自定义订阅页面。这允许您:
- 添加对不同 VPN 应用的支持
- 以多种语言自定义文本和说明
- 添加您自己的品牌(标志、公司名称、支持链接)
- 配置哪些应用显示为"精选"