Nginx 位置忽略不适用于上游

Nginx 位置忽略不适用于上游

为什么这个:

location /api/ {
    proxy_pass http://my_backend:3000/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

有效,但是这个:

location /api/ {
    resolver 127.0.0.11 ipv6=off valid=30s;
    set $upstream my_backend;
    proxy_pass http://$upstream:3000/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

才不是?

我想要做的就是代理除api后端之外的所有内容......

相关内容