nginx-proxy: 503 Service Temporarily Unavailable (Tried all the methods but still failed)

Hi, I am trying to use the nginix-proxy to expose the different containers to use the same port 80 for external connection.

I tried to follow the standard suggestion in https://cloud.google.com/community/tutorials/nginx-reverse-proxy-docker

Step 1:

docker run -d \
    --name nginx-proxy \
    -p 80:80 \
    -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

Step 2:

docker run -d --name site-a -e VIRTUAL_HOST=a.example.com nginx

However, I kept got the error “503 Service Temporarily Unavailable” when accessing “example.com” and

“This site can’t be reached a.example.com’s server IP address could not be found.” when accessing “a.example.com”

Following

https://github.com/jwilder/nginx-proxy/issues/582#issuecomment-249425260

I tried to

docker run -d -p 80:80 -e DEFAULT_HOST=a.example.com -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy:latest

Still cannot make it.

Following https://github.com/jwilder/nginx-proxy/issues/749

I tried to use the docker compose

version: '2'

services:

  blog:
    image: wordpress 
    container_name: wordpress
    environment:
      - VIRTUAL_HOST=blog.robota.asia
    expose:
      - "80"
    restart: always

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

networks:
  default:
    external:
      name: nginx-proxy

but same error remains, this is really quite frustrating, can anyone help on this?

This is what I see from the logs of the proxy container:

dockergen.1 | 2018/10/24 04:42:01 Received event die for container 66b3131df8e6 dockergen.1 | 2018/10/24 04:42:01 Generated ‘/etc/nginx/conf.d/default.conf’ from 1 containers dockergen.1 | 2018/10/24 04:42:01 Running ‘nginx -s reload’ dockergen.1 | 2018/10/24 04:42:01 Received event stop for container 66b3131df8e6 dockergen.1 | 2018/10/24 04:42:01 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification ‘nginx -s reload’ dockergen.1 | 2018/10/24 04:42:09 Received event start for container 83c86489b047 dockergen.1 | 2018/10/24 04:42:09 Generated ‘/etc/nginx/conf.d/default.conf’ from 2 containers dockergen.1 | 2018/10/24 04:42:09 Running ‘nginx -s reload’ dockergen.1 | 2018/10/24 04:42:09 Error running notify command: nginx -s reload, exit status 1 dockergen.1 | 2018/10/24 04:42:09 2018/10/24 04:42:09 [emerg] 33#33: no host in upstream “:80” in /etc/nginx/conf.d/default.conf:59

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (3 by maintainers)

Most upvoted comments

I narrowed this issue down to this block in /etc/nginx/conf.d/default.conf (at my end anyway):-

https://github.com/jwilder/nginx-proxy/blob/master/nginx.tmpl#L140

server {
	server_name _; # This is just an invalid value which will never trigger on a real hostname.
         .....
}

Before my other server stuff.

Removing the block allowed things to behave as I’d expect, but I’m at a loss why or how to remove this section without hacking the tmpl file and passing it in.

Same issue here. Adding the “depends_on” parameter didn’t help.

This happens to me frequently (40% of the time I start it up) while running on my local machine. After viewing the /etc/nginx/conf.d/default.conf when it does happen, looks like nothing is loaded into that file. It just has a single server block:

server {
	server_name _; # This is just an invalid value which will never trigger on a real hostname.
	listen 80;
	access_log /var/log/nginx/access.log vhost;
	return 503;
}

I haven’t noticed any particular pattern as to why it happens sometimes and not others. Any thoughts? Should I try out an older version of image?