
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 件のリクエストのうち 1 件では常に 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;
}
}