Apache virtual host proxy
I had to move some virtual hosts from one server (server "A") to another server (server "B") without changing DNS records for affected domains yesterday. This can be done easily with Apache's mod_proxy module. An example configuration of the server "A" is shown below:
-
<virtualhost *:*>
-
ProxyPreserveHost On
-
ProxyPass / http://192.168.111.2/
-
ProxyPassReverse / http://192.168.111.2/
-
ServerName hostname.example.com
-
</virtualhost>
The ProxyPreserveHost directive preserves the Host HTTP header, which is passed through to the proxied server configured by the ProxyPass directive. Virtual host's configuration on server "B" is the same, which was placed originally on server "A", e.g.:
-
<virtualhost *:*>
-
ServerName hostname.example.com
-
DocumentRoot /var/www/html/hostname.example.com
-
</virtualhost>
References:
Django REST applications and server with django-roa
If you are looking for ready-to-use Django REST server and clients solution, I recommend you the David Larlet's django-roa library. I have been using this library in testing environment from July 2009 with good testing results. The django-roa project is continuously improved, as can be seen on the project changelog.
VIM tab configuration for Django HTML templates
This tiny trick allows you to set tabs (and anything else of course) for Django template filetype. VIM has build-in filetype named "htmldjango", which does all the magic shown in the example configuration below.
An example .vimrc configuration file uses the "autocmd" VIM command, whis must be available in your installation.
-
if has("autocmd")
-
autocmd FileType htmldjango set tabstop=4|set shiftwidth=4|set expandtab
-
endif
Django multiple database support with DB switch feature
Our Django installation is capable to connect to as many databases as desired and switch between databases in according to session data. We reached this feature overriding several internal Django classes, according to recommendations on http://groups.google.com/group/django-users/msg/d1d7e0af565cc444?. All multiple database features are done without changes in original Django code.
Partial how-to can be found on http://kfalck.net/2009/07/01/multiple-databases-and-sharding-with-django too.
The solution is successfully tested for more than one month in real-world application and this application is going to be used into production environment soon.
For implementation details or questions leave a comment below.
Hello world!
Welcome to my first tech blog. This is my first post, which has established this website. Enjoy!
