Welcome! Log In Create A New Profile


Problem with "if" and "$remote_addr"

November 26, 2012 09:30PM

I have strange problem. If i enter phpinfo file i get:

So my IP is

I want to block access to location from other ips then ip in url. For example

location ~ ^/([0-9\.]+)/(.*?)$ {
if ($remote_addr != $1) {
return 404;

But it doesn't work correctly :(

1.) I will see value of variable $remote_addr, and it is correct result. The result is:
location ~ ^/([0-9\.]+)/(.*?)$ {
echo $remote_addr;
2.) I will check that $remote_addr is excaly parametr 1, and i get for the url "/"
location ~ ^/([0-9\.]+)/(.*?)$ {
if ($remote_addr != $1) {
echo "$remote_addr != $1";

And the result is " !="

The question: Why variable $remote_addr change value when i use "if"

Sorry for my english.

Thanks for reply
Subject Author Posted

Problem with "if" and "$remote_addr"

bar_gra November 26, 2012 09:30PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 214 on March 20, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready