Nginx http prefixes in upstream server

I'm trying to use nginx to proxy pass to two docker containers. Here is my upstream conf file:

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

This is what I get trying to load it:

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

Once I removed the http:// prefixes the error stopped occuring. Why is that?


Solution 1:

The upstream block is a list of servers with optional status pooling and connection restrictions. The protocol used to join theses servers must be specified in the proxy_pass directive.

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

server {

    [ ... ]

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

}

Solution 2:

Syntax: server address [parameters];The address can be specified as a domain name or IP address, with an optional port, or as a UNIX-domain socket path specified after the “unix:” prefix. I think you should like to look at "http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream".