Thu 1 Mar 2007
This post is about how to start django with nginx (with blocking undesirable bots and with installed base GeoIP).
Detailed installation for: nginx, django, django+fcgi, flup.
Regardless whether django is started in a threaded- or in a fork-mode, FastCGI is used for connection with server, through a socket or through a port.
There are these four versions of script for start, one of which it is necessary to put in the catalogue of your project:
* Threaded+socket
* Threaded+Port
* Fork+socket
* Fork+Port
Now a base configuration file for nginx will be created.
Nginx allows to include configuration from other files, that I have taken advantage of. I have divided into the basic file with the general adjustments, file with parameters for FastCGI, file with addresses of base GeoIP and files for each project/domain.
For GeoIP-module I have used the free version from a site maxmind.com and ip-to-country.webhosting.info, which by means of my utility and from a package nginx/contrib converted in acceptable appearance for the web-server.
Example:
In the basic config I have also included speed limit of uploading for different unnecessary search bots and blocking of the some spamers, there it is easy to add or remove something.
Here are all configuration files:
Detailed installation for: nginx, django, django+fcgi, flup.
Regardless whether django is started in a threaded- or in a fork-mode, FastCGI is used for connection with server, through a socket or through a port.
There are these four versions of script for start, one of which it is necessary to put in the catalogue of your project:
* Threaded+socket
* Threaded+Port
* Fork+socket
* Fork+Port
Now a base configuration file for nginx will be created.
Nginx allows to include configuration from other files, that I have taken advantage of. I have divided into the basic file with the general adjustments, file with parameters for FastCGI, file with addresses of base GeoIP and files for each project/domain.
For GeoIP-module I have used the free version from a site maxmind.com and ip-to-country.webhosting.info, which by means of my utility and from a package nginx/contrib converted in acceptable appearance for the web-server.
Example:
2.6.190.56/29 GB; 3.0.0.0/8 US; 4.0.0.0/12 US;It is possible to download prepared base on the countries at me (gzip 0.6MB). The variable $geo can be used in logs, and also is transferred in the application through FastCGI parameters, in django projects it can be get through request.META['GEO']
In the basic config I have also included speed limit of uploading for different unnecessary search bots and blocking of the some spamers, there it is easy to add or remove something.
Here are all configuration files:
nginx.conf django.conf fastcgi.conf bots.conf geoip.conf (gzip 0.6MB)The detailed information about django is here and here. About nginx: here.
English
Deutsch
Русский
(11 votes, average: 4.7 out of 5)
March 3rd, 2007 at 6:15 p.m.
Ich kenne nicht viele Deutsche, die in Django programmieren. Es ist wahrscheinlich bei uns seiner Zeit voraus :-) Schwer sich nach Ewigkeit mit PHP zusammen umzustellen, auch einsehend dass es die Vergangenheit ist.
Nach Ihrem vorigen Bericht sehe ich mich auch Nginx an. Es ist genauso schnell wie lighttpd, nach Bequemlichkeit finde ich es noch besser. Und was ist mit RAM-Verbrauch?
March 5th, 2007 at 12:26 a.m.
GeoIP hat 165.800 Adressen (3.4MB) (die über 1.000 zweifelhaften davon habe ich manuell geprüft :-))
Nginx hat ein Hauptprozess und 3 "worker_processes"
Bei mir Speicherverbrauch:
mit GeoIP = je Prozess 10MB
ohne GeoIP = je Prozess 1.5MB
March 6th, 2007 at 6:13 p.m.
I needed
fastcgi_param PATH_INFO $fastcgi_script_name;
to make it work.
Thanks!
March 6th, 2007 at 9:28 p.m.
This parameter is in "fastcgi.conf"
In your "django.conf" you have:
include conf/fastcgi.conf;
Doesn't it work?
March 7th, 2007 at 2:26 a.m.
The file is correct. I didn't copy the first 4 lines of the file. Why the hell, no clue. :)
Greetings
March 8th, 2007 at 12:33 a.m.
2 Kai: write exactly on my e-mail alrond (@) alrond . com
I can also speak german ;)