I am working on a project to manage the logs from clients, I am using nginx to redirect links in my projects. This my config file (I run nginx with docker):
user nginx;
worker_processes 1;
error_log /var/log/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 '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
client_body_timeout 128;
client_header_timeout 128;
keepalive_timeout 128;
proxy_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
#include /etc/nginx/conf.d/*.conf;
client_max_body_size 100M;
server {
listen 80;
server_name sale.ala.vn;
rewrite ^.*$ https://$host$request_uri break;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl.crt/cert.crt;
ssl_certificate_key /etc/nginx/ssl.key/private.key;
root /usr/share/nginx/html;
server_name sale.ala.vn;
location / {
rewrite ^/$ $scheme://$host/msale/ break;
proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://10.10.34.162;
}
}
}
I want to get the real client IP using spring boot, but the result that I got is always the IP of nginx. How can I fix this? Thank you so much.