Browse Source

correctly set remote addr from x-forwarded-for

dev
Adrian Malacoda 1 year ago
parent
commit
ada88102c6
1 changed files with 13 additions and 2 deletions
  1. 13
    2
      configuration/nginx.conf

+ 13
- 2
configuration/nginx.conf View File

@@ -53,8 +53,14 @@ http {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
include fastcgi_params;

# https://stackoverflow.com/a/36451158
set $realip $remote_addr;
if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
set $realip $1;
}
fastcgi_param REMOTE_ADDR $realip;
}
}

@@ -84,8 +90,13 @@ http {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REMOTE_ADDR $http_x_real_ip;
include fastcgi_params;

set $realip $remote_addr;
if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
set $realip $1;
}
fastcgi_param REMOTE_ADDR $realip;
}
}
}

Loading…
Cancel
Save