我有两个 nginx 配置。一个是我的 CDN:
server {
server_name cdn.***.xyz;
root /var/www/html;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cdn.***.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cdn.***.xyz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = cdn.***.xyz) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name cdn.***.xyz;
listen 80;
return 404; # managed by Certbot
}
另一个:
server {
listen 80;
server_name voting.***.tk;
location / {
proxy_pass http://127.0.0.1:12349;
}
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;
}
当我访问 voting.***.tk 时,出现 403 Forbidden 错误。在 nginx 错误日志中:
2023/12/03 10:57:49 [error] 2203089#2203089: *297 directory index of "/var/www/html/" is forbidden, client: 117.216.149.175, server: cdn.***.xyz, request: "GET / HTTP/2.0", host: "voting.***.tk"