nginx-proxy icon indicating copy to clipboard operation
nginx-proxy copied to clipboard

Error during the nginx's refresh

Open jermorin opened this issue 11 years ago • 6 comments

I run these simple commands, that's missing me?

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

==> 49d31d23e948
docker run  -e 'VIRTUAL_HOST=web.domain.com' 
            -v $(pwd):/usr/share/nginx/html:ro 
            --expose 80 
            -d nginx

$(pwd) : contain index.html with helloWorld.

root@jermorin:~# docker logs 49d31d23e948
forego     | starting nginx.1 on port 5000
forego     | starting dockergen.1 on port 5100
dockergen.1 | 2015/10/07 17:01:48 Generated '/etc/nginx/conf.d/default.conf' from 1 containers
dockergen.1 | 2015/10/07 17:01:48 Running 'nginx -s reload'
dockergen.1 | 2015/10/07 17:01:48 Watching docker events
dockergen.1 | 2015/10/07 17:01:58 Received event start for container a87c828bafb2
dockergen.1 | 2015/10/07 17:01:58 Generated '/etc/nginx/conf.d/default.conf' from 2 containers
dockergen.1 | 2015/10/07 17:01:58 Running 'nginx -s reload'
dockergen.1 | 2015/10/07 17:01:58 Error running notify command: nginx -s reload, exit status 1

Thank you in advance for your help

jermorin avatar Oct 07 '15 17:10 jermorin

Can you run docker exec -ti <nginx-proxy-id> nginx -t to do a syntax test? you can also cat the generated config with docker exec -ti <nginx-proxy-id> cat /etc/nginx/conf.d/default.conf

wader avatar Oct 07 '15 18:10 wader

docker exec -ti nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

docker exec -ti cat /etc/nginx/conf.d/default.conf

# If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the
# scheme used to connect to this server
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
  default $http_x_forwarded_proto;
  ''      $scheme;
}

# If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any
# Connection header that may have been passed to this server
map $http_upgrade $proxy_connection {
  default upgrade;
  '' close;
}

gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

log_format vhost '$host $remote_addr - $remote_user [$time_local] '
                 '"$request" $status $body_bytes_sent '
                 '"$http_referer" "$http_user_agent"';

access_log off;


# HTTP 1.1 support
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;


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;
}

upstream web.doma.in {
            # lonely_archimedes
            server xxx.xx.xx:80;
}
server {
    server_name web.doma.in;
    listen 80 ;
    access_log /var/log/nginx/access.log vhost;
    location / {
        proxy_pass http://web.doma.in;
    }
}

jermorin avatar Oct 07 '15 18:10 jermorin

Strange, do you see anything interesting in docker logs <nginx-proxy-id>? also maybe interesting to start a shell docker exec -ti <nginx-proxy-id> bash and try start nginx manually.

wader avatar Oct 07 '15 19:10 wader

Managed to figure it out?

wader avatar Oct 10 '15 16:10 wader

I am not come to reproduce the problem, I just rm containers. I clearly had a routing problem, I thought it was the proxy, but it came from the DNS. Thank you for your help. Now, work fine !

jermorin avatar Oct 10 '15 17:10 jermorin

Ok :+1:

wader avatar Oct 10 '15 17:10 wader