Allow directive with variables

I am trying to use a variable with the allow directive, i.e.

set $home_ip 1.2.3.4;

location ^~ /apc/ {
  # Allow home
  allow $home_ip;

  deny all;

  include /etc/nginx/php.conf;
}

But I am getting an error. Does the allow directive allow variables?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,234600,234600#msg-234600

Hello!

On Mon, Dec 31, 2012 at 07:51:21PM -0500, justin wrote:

  include /etc/nginx/php.conf;
}

But I am getting an error. Does the allow directive allow variables?

No, variables are not allowed within the “allow” directive
parameters. If a parameter can contain variables, it’s indicated
in a directive description.

Note well: it’s bad idea to use variables to shorten configs, see
http://nginx.org/en/docs/faq/variables_in_config.html.


Maxim D.
http://nginx.com/support.html

An easy way to solve this issue is to create a “allowmyip.conf” file and
include it anywhere you wish.

allowmyip.conf file :

allow 11.22.33.44
deny all;

Then in your server block :location ^~ /apc/ {
# Allow home

include /etc/nginx/allowmyip.conf;

}

This way it will be real easy to manage if your IP address changes. Just
update your IP Address in the allowmyip.conf file and restart the
server.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,234600,257423#msg-257423

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs