Docker Community Forums

Share and learn in the Docker community.

dynamic upsteam proxy_pass does not work



Hi, I use nginx:latest in a kubernetes cluster which forwards traffice to upstream service svc-web. I have the following nginx config:

    user nginx;
    worker_processes  auto;
    # set open fd limit to 30000
    #worker_rlimit_nofile 10000;
    error_log  /var/log/nginx/error.log;
    events {
      worker_connections  10240;  
    http {  
      log_format  main
      access_log /var/log/nginx/access.log main;
      rewrite_log on;
      upstream svc-web {
        server svc-web:8080;
        keepalive 1024;
      server {
        listen 80;
        access_log /var/log/nginx/app.access_log main;
        error_log /var/log/nginx/app.error_log;
        resolver [::1]:5353 valid=10s;
        set $upstream http://svc-web;
        location / {
          proxy_pass $upstream;
          proxy_http_version 1.1;

Unfortunately, it doesn’t work when I restart my upstream service which results in change of IP address of the service. /var/log/app.error_log shows that nginx still use the old IP address. Any advice and insight is appreciated. Relevant post: