目前,我们正在使用nginx作为我们主要的前端服务器,以Mesos-DNS为基础的dynamicDNS服务发现支持的一组服务。
我们的nginxconfiguration看起来有点像这样;
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,这是没有意义的,因为在集群内运行的服务没有移动到不同的从设备。
现在,parsing器valid=1s是相当积极的,所以我们把它延长到更长的时间,认为也许是太频繁地查询DNS。 但是,任何价值都会导致同样的问题。 删除valid=xx也没有帮助。
这里发生了什么? 我们如何减轻这一点?
谢谢。
编辑(完整configuration)
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; } }