上游服务器中的Nginx http前缀


12

我正在尝试使用Nginx代理传递给两个Docker容器。这是我的上游conf文件:

upstream api_servers {
  server http://192.168.49.4:49155;
  server http://192.168.49.4:49156;
}

这是我尝试加载的内容:

nginx: [emerg] invalid host in upstream "http://192.168.49.4:49155" in /etc/nginx/conf.d/api_upstream.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed

一旦删除了http://前缀,错误就会停止发生。这是为什么?

Answers:


16

上游块是具有可选状态池和连接限制的服务器列表。必须在proxy_pass伪指令中指定用于加入这些服务器的协议。

upstream api_servers {
    server 192.168.49.4:49155;
    server 192.168.49.4:49156;
}

server {

    [ ... ]

    location /foo/ {
        proxy_pass http://api_servers/;
    }

}

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.