nginx反向代理IPv6配置

项目是集群环境,要求IPv4/IPv6双栈支持,nginx反向代理配置如下:

upstream sa{

    server 172.16.0.216:8080;   #SA Server1
    server 172.16.0.232:8080;   #SA Server2
}
upstream sa_ipv6{
    server [2001:470:fb3c:0:f816:3eff:fed0:2ae2]:8080;   #SA Server1
    server [2001:470:fb3c:0:f816:3eff:fe68:27b3]:8080;   #SA Server2
}


server {
    listen       80;  ## listen for ipv4
    server_name  localhost;


    location / {
        #index index.html;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass   http://sa;
    }
}
server {
    listen [::]:80 ipv6only=on;  ## listen for ipv6
    server_name  localhost;


    location / {
        #index index.html;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass   http://sa_ipv6;
    }
}

你可能感兴趣的:(IPv6)