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
'remote_addr:$remote_addr\t'
'time_local:$time_local\t'
'method:$request_method\t'
'uri:$request_uri\t'
'host:$host\t'
'status:$status\t'
'bytes_sent:$body_bytes_sent\t'
'referer:$http_referer\t'
'useragent:$http_user_agent\t'
'forwardedfor:$http_x_forwarded_for\t'
'request_time:$request_time';
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 127.0.0.1 [::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: https://github.com/ubuntu/microk8s/issues/224