Last Updated: February 25, 2016
·
1.342K
· cicerocomp

Adding remote IP in javascript with nginx

js.js:

var IP = "###IP###";

nginx.conf (location):

sub_filter "###IP###" "$remote_addr";
sub_filter_once on;
sub_filter_types application/x-javascript;

This module can search and replace text in the nginx response. It is only available if the:

--with-http_sub_module option