Blog entries on May 2009

  • Getting the client IP address behind a proxy in Apache

    By Nuno Mariz, on 20 May 2009 @ 09:45

    Typically in my Django projects deployments I use Nginx as a front-end web server to handle static content while proxying all other requests to Apache.

    When the request arrives to Apache, the client IP address is 127.0.0.1. We need to configure Apache to accept the IP address from X-Real-IP or X-Forwarded-For headers set by Nginx.

    To solve this problem I use mod_rpaf that does exactly the opposite of mod_proxy_add_forward.

    In my Nginx virtualhost configuration I have something like:

    server {
        ...
        location  / {
            proxy_pass        http://127.0.0.1:8080;
            proxy_set_header  Host             $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            ...
        }
        ...
    }
    

    This also applies if your are using a different webserver as front-end such as Lighttpd or another instance of Apache.

  • Portuguese Python User Group

    By Nuno Mariz, on 18 May 2009 @ 08:45
    Python Portugal
    I've created a Python User Group in Portugal. The idea is to join people who enjoy programming in Python.
    No membership is required to participate, experienced programmers and absolute beginners are both welcome!
    You can visit the site or follow us on Twitter.