Skip to content

Instantly share code, notes, and snippets.

View migonzalvar's full-sized avatar

Miguel Gonzalez migonzalvar

  • Vigo, Pontevedra, Spain
View GitHub Profile

Serving Django and Twisted using HAproxy

Why?

Because we wanted to achive the following while developing a webapp using websockets:

Static serving (nginx), Django application (gunicorn) and Websockets service (twisted)

  • on the same IP

Why?

Most commonly because you'd like to use JDBC to connect to your local Postgres server without using password auth. Very quickly you'll realise Unix sockets aren't supported in Java, so you can't use peer authentication.

How?

First, ensure your /var/lib/pgsql/pg_hba.conf uses ident for TCP/IP connections:

# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
import os
import re
import time
import subprocess
import ajenti
from ajenti.api import *
from ajenti.api.http import *
from ajenti.plugins import manager