WebFaction
Community site: login faq

I need to block access to my Django app from a certain country. AFAIK, mod_geoip is the best option, but not available.

Support have directed me to build the module from scratch and pointing me to generic help files (I know virtually nothing about UNIX and the make process). These direct me to run apxs, which doesn't appear to exist. So now I'm stuck.

Can anyone please advise what the most painless route to getting geoip based blocking going on a Webfaction django site might be ?

Thank you very much.

asked 28 Jul '11, 11:04

rich
313
accept rate: 0%

edited 30 Jul '11, 07:23


If you want painless, then you can forgo using mod_geoip altogether and instead block specific IPs or IP ranges via mod_setenvif and mod_authz_host.

To do that, first add setenvif_module and authz_host_module to your modules in httpd.conf, if you've not done so already:

LoadModule setenvif_module modules/mod_setenvif.so
LoadModule authz_host_module modules/mod_authz_host.so

Then, set a variable ('blocked' for example, but you can call it anything you want):

# "xxx\.xxx\.xxx\.xxx" is a regular expression.
# You can modify it to allow multiple IPs, ranges of IPs, etc.
SetEnvIf X-Forwarded-For xxx\.xxx\.xxx\.xxx blocked

Finally, allow access based on the variable:

<Location "/">
 Order Allow,Deny
 Allow from all
 Deny from env=blocked
</Location>

If you want to go the painful route and use mod_geoip, then you'll need to build the full stack from source, including:

  • Apache
  • mod_wsgi
  • GeoIP
  • mod_geoip

You can find some instructions for building Apache and mod_wsgi in our old forum. This will also build apxs which you can use later to build mod_geoip.

We also have instructions for building GeoIP. You can skip the steps for installing the Python binding if you don't need that.

Instructions for building and configuring mod_geoip are available here: MaxMind - GeoIP Apache API

Hope that helps! Please let us know if you have any further questions.

permanent link

answered 28 Jul '11, 11:45

seanf
12.2k41836
accept rate: 37%

edited 28 Jul '11, 11:46

Seanf - thank you very much - plenty to work with there.

r.

(28 Jul '11, 11:57) rich

You're very welcome!

(28 Jul '11, 12:06) seanf

UPDATE: Sean (web faction support) emailed me directly and could not have been more helpful. All fixed up and blocking happily.

permanent link

answered 30 Jul '11, 07:22

rich
313
accept rate: 0%

edited 30 Jul '11, 07:22

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×225
×10

question asked: 28 Jul '11, 11:04

question was seen: 4,484 times

last updated: 30 Jul '11, 07:23

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM