6

nginx 反代 upstream 不支持域名只能支持 ip?

 1 year ago
source link: https://www.v2ex.com/t/883466
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  程序员

nginx 反代 upstream 不支持域名只能支持 ip?

  kisshere · 8 小时 41 分钟前 · 1323 次点击
upstream backend {
    server 127.0.0.1;
    keepalive 8;
}

server {
    listen 80;

    location / {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
    }
}

如果把 www.abc.com 在 hosts 文件中解析为 127.0.0.1 ,然后

upstream backend {
    server www.abc.com;
    keepalive 8;
}

nginx 反代就失败了,nginx 这么低级?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK