Skip to content

Commit

Permalink
Merge pull request #958 from amazeeio/fastcgi-remote-addr-clean
Browse files Browse the repository at this point in the history
remove `::ffff:` also from fastcgi param `REMOTE_ADDR`
  • Loading branch information
Schnitzel committed Mar 10, 2019
2 parents a473e54 + 133b8cf commit dcf9735
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion images/nginx/fastcgi.conf
Expand Up @@ -5,6 +5,14 @@ if ($http_x_forwarded_proto = 'https') {
set $fastcgi_port "443";
}

set_by_lua_block $remote_addr_clean {
if string.find(ngx.var.remote_addr, "^::ffff:") then
return string.match(ngx.var.remote_addr, "^::ffff:(.*)"))
else
return ngx.var.remote_addr
end
}

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
Expand All @@ -23,7 +31,7 @@ fastcgi_param HTTPS $fastcgi_https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_ADDR $remote_addr_clean;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;

Expand Down

0 comments on commit dcf9735

Please sign in to comment.