# Hashes / Arrays für $arg\_PARAMETER

**URL:** <https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928>\
**Category:** NGINX\
**Created:** [July 24, 2013, 10:29pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928 "2013-07-24T22:29:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [July 24, 2013, 10:29pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928/1 "2013-07-24T22:29:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![maikungeriok](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@maikungeriok](https://www.ruby-forum.com/u/maikungeriok)\
**Post date:** [July 25, 2013, 12:04pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928/2 "2013-07-25T12:04:20Z")

</div>

On 24 Jul 2013 21:30, “Maik U.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![maikungeriok](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@maikungeriok](https://www.ruby-forum.com/u/maikungeriok)\
**Post date:** [July 25, 2013, 1:34pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928/3 "2013-07-25T13:34:34Z")

</div>

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:

> **[Website Domain Names, Online Stores & Hosting - Domain.com](https://www.domain.com/?user=test)**
>
> Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.

$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.

---

<div class="post-metadata">

**Author:** ![maikungeriok](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@maikungeriok](https://www.ruby-forum.com/u/maikungeriok)\
**Post date:** [July 25, 2013, 4:27pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928/4 "2013-07-25T16:27:16Z")

</div>

On 25 Jul 2013 12:34, “Maik U.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![maikungeriok](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@maikungeriok](https://www.ruby-forum.com/u/maikungeriok)\
**Post date:** [July 25, 2013, 2:52pm UTC](https://www.ruby-forum.com/t/hashes-arrays-fur-arg-parameter/235928/5 "2013-07-25T14:52:03Z")

</div>

On Thu, Jul 25, 2013 at 8:34 PM, Maik U. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> array (“test”; "test2)
> 
> Query-String:
> 
> [http://domain.com/?user=test](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](http://www.asciiribbon.org)
