How to configure x-forwarded-for in ASP for nginx access logs to show real ip?
We have a website with Nginx on Azure App Service Plan (ASP). We are analysing the access logs to find the geo locations of our visitors through IP addresses. ASP has a virtual IP and access logs do not show the actual IP of the visitors. There seems to be a way to configure Access Restrictions to populate x-forwarded-for field which we have setup in the Nginx configuration. I have used the inbound IP of our App Service Plan, the configuration is not working and the Azure documentation is not helpful. Nginx.conf file is:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log error;
pid /var/run/nginx.pid;
events {
worker_connections 2048;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" ';
access_log /var/log/nginx/access.log;
sendfile on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/modules-enabled/*.conf;