第13章 NGINX 反向代理配置详解
NGINX 反向代理配置
这是一份非常基础的反向代理配置,使用 Let's Encrypt 证书保障安全。所有日志默认关闭。请记得将 server_name 替换为你的域名。
server { listen 80; listen [::]:80; listen 443 ssl; listen [::]:443 ssl; http2 on;
server_name invidious.domain.tld;
access_log off; error_log /var/log/nginx/error.log crit;
ssl_certificate /etc/letsencrypt/live/invidious.domain.tld/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/invidious.domain.tld/privkey.pem;
location / { proxy_pass http://127.0.0.1:3000; # 为了让备用域名正常工作,请查看 Invidious 的 `config.example.yml` # 文件以获取更多信息。 proxy_set_header X-Forwarded-Host $host; proxy_http_version 1.1; # 保持连接 proxy_set_header Connection ""; # 保持连接 }
if ($https = '') { return 301 https://$host$request_uri; } # 若未通过 HTTPS 连接,则永久重定向至 HTTPS }