I successfully configured a two image multi-container instance on the azure cloud, but in my nginx access logs I retrieve only what I think to be internal IPs (10.240.xxx.xx). This happens already after having implemented the real IP package for nginx.
My guess is that container instances are masked behind a common load balancer dedicated for the specific pool.
I instantiate the container instance through the command:
az container create
Here there is my default nginx configuration:
user nginx;
worker_processes 1;
error_log /preferred/path/nginx_error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$proxy_add_x_forwarded_for - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent"' ;
access_log /preferred/path/nginx_access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
daemon off;
and here my site configuration:
server {
listen 80;
set_real_ip_from xxx.xx.xxx.x/xx;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location / {
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
proxy_pass http://localhost:5000;
}
}
I set the real IP from a cloudfare post. So far it seemed the most reliable and up to date.
Does anyone know what happens exactly? Is it possible anyhow to get the real client IP through any other header? It is also possible that there is something incorrect in the way I set up the real IP, but all the documentation I found online was rather confusing to me.