我已经为我的子域创建了反向代理配置,但运行时nginx -t
它发出警告[warn] conflicting server name "img.somedomain.com" on 0.0.0.0:80, ignored
proxy_cache_path /root/cache-proxy levels=1:2 keys_zone=pximg:10m max_size=10g inactive=7d use_temp_path=off;
server {
server_name img.somedomain.com;
listen 80;
access_log off;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/letsencrypt/live/img.somedomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/img.somedomain.com/key.pem;
ssl_trusted_certificate /etc/letsencrypt/live/img.somedomain.com/ca.pem;
ssl_stapling_verify on;
location / {
proxy_cache pximg;
proxy_pass https://i.pximg.net;
proxy_cache_revalidate on;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_set_header Host i.pximg.net;
proxy_set_header Referer "https://www.pixiv.net/";
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
proxy_cache_valid 200 7d;
proxy_cache_valid 404 5m;
}
}
反向代理确实有效,但我不知道是什么导致了服务器名称冲突,因为我的配置中没有看到任何重复项。有人能帮我清理一下我的配置吗?
答案1
您应该查看所有 nginx 配置以查找是否有另一个配置文件包含相同的域。
您可以使用grep -R "img.somedomain.com" /etc/nginx/
它来执行搜索。确保/etc/nginx/
这是您的 nginx 配置路径。