I have nginx conf as follows:
server {
listen 127.0.0.1:8080;
server_name 127.0.0.1;
client_max_body_size 20m;
include /etc/nginx/conf.d/services/*.conf;
# redirect server error pages to the static page /50x.html
#
error_page 500 /500.json;
error_page 501 /501.json;
error_page 502 /502.json;
error_page 503 /503.json;
error_page 504 /504.json;
error_page 404 /404.json;
location = /500.json {
root /opt/lj/nginx;
}
location = /501.json {
root /opt/lj/nginx;
}
location = /502.json {
root /opt/lj/nginx;
}
location = /503.json {
root /opt/lj/nginx;
}
location = /504.json {
root /opt/lj/nginx;
}
location = /404.json {
root /opt/lj/nginx;
}
}
In the conf.d/services directory, I have a file with:
location /api/auth {proxy_pass http://127.0.0.1:8081;}
I have an upstream process listening on 8081 for requests. Almost accurately 2 our 3 times, the request gets redirected appropriately, but every third time, I get this error:
2014/10/09 03:03:52 [alert] 4572#0: *16 socket() failed (97: Address family not supported by protocol) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET /api/auth/1.0/companies/1/clients HTTP/1.1", upstream: "http://[::1]:8081/api/auth/1.0/companies/1/clients", host: "localhost:8080"
I don't know how to make nginx only forward to the IPv4 address which the upstream understands.
Access logs: (Please note 1 out of 3 attempts results in 500 while the rest pass)
127.0.0.1 - portalAdmin [09/Oct/2014:02:56:37 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 500 107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:02:57:38 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:02:57:39 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:02:57:41 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 500 107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:44 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:45 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:46 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 500 107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:50 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:51 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
127.0.0.1 - portalAdmin [09/Oct/2014:03:03:52 -0400] "GET /api/auth/1.0/companies/1/clients HTTP/1.1" 500 107 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36" "98.207.234.244"
Any help would be greatly appreciated! Thanks.