Forum: NGINX Hashes / Arrays für $arg_PARAMETER

88fbe7dfc741de73802a686564fac0d8?d=identicon&s=25 Maik Unger (maikungeriok)
on 2013-07-24 22:29
Hello @all,

Is it possible to define array / hashes in nginx? I have the following
idea:

nginx should check $arg_PARAMETER which is defined by an array. If the
right element in the array, then die access is permitted, otherwise
denied.

example:

the $arg_PARAMETER can have the following values:

"ab" or "bc" or cd"

if $arg_PARAMATER != array -> Access is denied, otherwise permitted

I would appreciate about a solution.

Regards,

Maik
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2013-07-25 12:04
(Received via mailing list)
On 24 Jul 2013 21:30, "Maik Unger" <lists@ruby-forum.com> wrote:
> example:
>
> the $arg_PARAMETER can have the following values:
>
> "ab" or "bc" or cd"
>
> if $arg_PARAMATER != array -> Access is denied, otherwise permitted

$arg_* are strings because they derive from the query string.  They are
not
arrays. You can interpret these strings using any of the methods nginx
gives you.

> I would appreciate about a solution.

I suggest you'll have to concoct a solution using nginx maps with
regular
expressions. That's a very powerful method of switching behaviours based
on
user input. Have a Google for their docs and for interesting ways of
using
them.

J
88fbe7dfc741de73802a686564fac0d8?d=identicon&s=25 Maik Unger (maikungeriok)
on 2013-07-25 13:34
hi,

i think that you don't understand me.

i will define an array that will check against the $arg_PARAMETER.

Example:

Array with the following Values:

array ("test"; "test2)

Query-String:

http://domain.com/?user=test

$arg_user = "test"

if the $arg_PARAMETER match with on of the array values, the access to
the webseite is allow, otherwise the access is disallowed.
B459184a1a76aadb382353b20988ccfa?d=identicon&s=25 edogawaconan (Guest)
on 2013-07-25 14:52
(Received via mailing list)
On Thu, Jul 25, 2013 at 8:34 PM, Maik Unger <lists@ruby-forum.com>
wrote:
> array ("test"; "test2)
>
> Query-String:
>
> http://domain.com/?user=test
>
> $arg_user = "test"
>
> if the $arg_PARAMETER match with on of the array values, the access to
> the webseite is allow, otherwise the access is disallowed.
>

Something like this should work:

map $arg_user $allowed {
  default 0;
  test 1;
  test2 1;
}

--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2013-07-25 16:27
(Received via mailing list)
On 25 Jul 2013 12:34, "Maik Unger" <lists@ruby-forum.com> wrote:
>
> hi,
>
> i think that you don't understand me.

I understand you just fine. You want to use the nginx config language in
a
way it can't be, because it's not a general purpose language and the
implementors didn't put in the specific feature you want to use. I've
given
you a pointer towards the nginx-y way of achieving the end result you've
described.

HTH,
J
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.