前记
给Aria2服务器所用的SSL证书往往不支持Aria2所使用的6800端口,为此就需要用Nginx来实现同时提供HTTP和Aria2 JSONRPC服务了。但是群晖 UI
界面的反代没有办法编辑配置。
解决思路
想到的解决方案有两个,第一是通过 Docker
再装一个 Nginx
来做反代,第二是通过群晖自身的 Nginx
来做反代;最后选择了通过自身 Nginx
来做反代
Nginx配置
/usr/syno/etc/certificate/system/default/
为群晖安全性->证书
上传的默认证书的存储位置
5001
端口为 群晖
的默认SSL访问端口,6880、6800
为aria2 跟rpc的docker在用端口
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| server {
listen 5001 ssl http2; listen [::]:5001 ssl http2; server_name dl.zjylyf.fun; ssl_certificate /usr/syno/etc/certificate/system/default/fullchain.pem; ssl_certificate_key /usr/syno/etc/certificate/system/default/privkey.pem; ssl_session_timeout 4h; ssl_protocols TLSv1.2 TLSv1.3; ssl_buffer_size 4k;
if ($scheme = http) { return 301 https://$host$request_uri; }
location / {
proxy_pass http://127.0.0.1:6880;
proxy_set_header Host $host:$server_port;
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_redirect http:// https://;
}
location /jsonrpc {
proxy_pass http://localhost:6800/jsonrpc;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
error_page 403 404 500 502 503 504 @error_page;
location @error_page {
root /usr/syno/share/nginx;
rewrite (.*) /error.html break;
allow all;
}
}
|
链接配置
将配置文件链接到 /etc/nginx/sites-enabled/
ln -s /xx/xx/xxx.com.conf /etc/nginx/sites-enabled/
重启
最后只需要重启 Nginx
即可
sudo systemctl --restart nginx
重载入nginx配置即可,无需重启nginx
nginx -s reload