# Map Module and Domains

**URL:** <https://www.ruby-forum.com/t/map-module-and-domains/221173>\
**Category:** NGINX\
**Created:** [July 3, 2012, 7:02pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173 "2012-07-03T19:02:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 3, 2012, 7:02pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173/1 "2012-07-03T19:02:16Z")

</div>

Ok, I was reading up on the map module and it seems the right way to do  
this, howeaver I really couldnt think of a way to do this (without just  
using the if alternative way).

Blocking domains is what I want to do, my server blocks are per IP  
accepting everything for any domain, howeaver I want to filter certain  
[blocked] domains away by way of proxy passing or redirecting to another  
URL.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 4, 2012, 5:46pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173/2 "2012-07-04T17:46:01Z")

</div>

And I take it that the first block is the ‘default’ so I should add my  
‘bad-site’ block last like you have? Just clarification.

I really like the way you did this, way more clean than the if based  
system  
I was planning to use (and less evil).

On Wed, Jul 4, 2012 at 3:23 AM, Oleksandr V. Typlyns’kyi  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 3, 2012, 7:23pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173/3 "2012-07-03T19:23:20Z")

</div>

Tomorrow Jul 4, 2012 at 03:01 SplitIce wrote:

> Ok, I was reading up on the map module and it seems the right way to do  
> this, howeaver I really couldnt think of a way to do this (without just  
> using the if alternative way).
> 
> Blocking domains is what I want to do, my server blocks are per IP  
> accepting everything for any domain, howeaver I want to filter certain  
> [blocked] domains away by way of proxy passing or redirecting to another  
> URL.

You can use another server block for that domains.  
[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)

server {  
listen 192.168.1.1:80;  
…  
}

server {  
listen 192.168.2.2:80;  
…  
}

server {  
listen 192.168.1.1:80;  
listen 192.168.2.2:80;  
server\_name [blocked.example.org](http://blocked.example.org) _.filtered.net badsite._;  
…  
}

–  
WNGS-RIPE

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 5, 2012, 4:53pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173/4 "2012-07-05T16:53:18Z")

</div>

On Thu, Jul 05, 2012 at 12:56:43AM +0300, Oleksandr V. Typlyns’kyi  
wrote:

> Today Jul 5, 2012 at 01:45 SplitIce wrote:
> 
> > And I take it that the first block is the ‘default’ so I should add my  
> > ‘bad-site’ block last like you have? Just clarification.
> > 
> > I really like the way you did this, way more clean than the if based system  
> > I was planning to use (and less evil).
> 
> It doesn’t metter if you add default\_server parameter to the right place.  
> [Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 4, 2012, 11:57pm UTC](https://www.ruby-forum.com/t/map-module-and-domains/221173/5 "2012-07-04T23:57:24Z")

</div>

Today Jul 5, 2012 at 01:45 SplitIce wrote:

> And I take it that the first block is the ‘default’ so I should add my  
> ‘bad-site’ block last like you have? Just clarification.
> 
> I really like the way you did this, way more clean than the if based system  
> I was planning to use (and less evil).

It doesn’t metter if you add default\_server parameter to the right  
place.  
[Module ngx\_http\_core\_module](http://nginx.org/en/docs/http/ngx_http_core_module.html#listen)

–  
WNGS-RIPE
