동적 업스트림 서버가 있는 nginx Proxy_pass

동적 업스트림 서버가 있는 nginx Proxy_pass

nginx우리는 현재 Mesos-DNS를 사용한 동적 DNS 기반 서비스 검색으로 지원되는 일련의 서비스에 대한 기본 프런트엔드 서버로 사용하고 있는 상황에 봉착했습니다 .

nginx 구성은 다음과 같습니다.

http {
  resolver 10.10.1.1 valid=1s; // some internal DNS server
}

server {
  set $core_api core-api-service.marathon.mesos; // some internal DNS
  location /api {
    proxy_pass $core_api:8080; // resolve core_api DNS dynamically to one of the IP's of the slave the process is running + listening on
  }
}

이제 문제는 이 설정이 올바르게 작동하지만 4~5개의 요청 중 하나가 항상 Nginx에서 404를 반환한다는 것입니다. 이는 클러스터 내부에서 실행되는 서비스 중 어느 것도 다른 슬레이브로 이동되지 않았기 때문에 의미가 없습니다.

이제 확인자는 valid=1s매우 공격적이므로 DNS를 너무 자주 쿼리하는 것일 수도 있다고 생각하여 더 오랜 기간으로 확장했습니다. 그러나 거기에 있는 모든 값은 동일한 문제를 야기합니다. 제거해 valid=xx도 도움이되지 않습니다.

여기서 무슨 일이 일어나고 있는 걸까요? 이를 어떻게 완화할 수 있나요?

감사해요.

편집(전체 구성)

server {
    listen       80;
    server_name  .myapp.com;
    return       301 https://www.myappname.com$request_uri;
}

server {
        listen   80;

        gzip on;
        gzip_min_length  1100;
        gzip_buffers  4 32k;
        gzip_types    text/plain application/x-javascript text/xml text/css;
        gzip_vary on;

        root /usr/share/nginx/www;
        index index.html index.htm;
        include /etc/nginx/mime.types;
        server_name api.myappname.com;
        error_page 404 /static/404.html;
        error_page 403 /static/404.html;
        error_page 503 /static/503.html;
        error_page 502 /static/502.html;
        set $core_api http://core_api.marathon.mesos;

        location /api {
                if ($http_x_forwarded_proto != 'https') {
                        rewrite ^ https://$host$request_uri? permanent;
                }
                limit_req   zone=one  burst=35;
                limit_req_status 503;
                proxy_pass            $core_api:8080;
                proxy_set_header      X-Real-IP  $remote_addr;
        }
}

관련 정보