同时反向代理 IPv4 地址和 IPv6 地址
步骤
反向代理需要加入 upstream 块,用于同时代理 ipv4 和 ipv6 地址。
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 |
upstream 名字(不能重复) { server IPv4地址:端口; server [IPv6地址]:端口; } server { listen 80; listen [::]:80; server_name 域名; return 301 https://$host$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name 域名; ssl_certificate 密钥路径; ssl_certificate_key 密钥路径; location / { 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_pass http://upstream 名字; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } client_max_body_size 1000m; } |
THE END