I have nginx reverse proxying to a golang server, each in its own docker container and running normally. I keep getting this error in nginx when trying to connect to Go container, BOTH on my local Mac machine and on the production server Linux Debian. It was working on my local Mac machine a week ago and all of a sudden it doesn't anymore
nginx_1 | 2017/09/28 01:29:54 [error] 5#5: *12 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.23.0.1, server: , request: "GET /api/about HTTP/1.1", upstream: "http://67.199.248.12:8080/api/about", host: "localhost"
can someone explain what's going on here? What is 67.199.248.12 and why isn't Nginx able to ping/connect to the Go container?
here's what's inside /etc/hosts in Go container
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.23.0.5 31f4103f002c
here's my nginx.conf
upstream gogo {
server go:8080 weight=10 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
location /api/ {
resolver 127.0.0.1 valid=30s;
proxy_pass http://gogo;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
I'm using docker-compose v3 to run nginx and docker
nginx:
restart: always
image: nginx
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "80:80"
command: /bin/bash -c "nginx -g 'daemon off;'"
go:
build:
context: ./api
expose:
- "8080"
depends_on:
- nginx
go code:
func main() {
router := mux.NewRouter().StrictSlash(true)
router.HandleFunc("/api/about", About).Methods("GET")
log.Fatal(http.ListenAndServe(":8080", router))
}