You searched for articles tagged with nginx.

[ #118 ] nginx -> Django fcgi SSL! Permalink

nginx, Django Added a year and a bit ago and last edited a year and a bit ago

I have setup nginx as my webserver. It acts as a proxy in front of the django site running it's own fcgi server:

# from within your django project, run the fcgi server as such (must have flup installed)
/usr/bin/env python manage.py runfcgi host=127.0.0.1 port=8080 --settings=settings

I use SSL middleware in my django site to automatically redirect to https:// for certain URLs - mainly /admin/

My nginx.conf has to have two server configs, one for HTTP and one for HTTPS:

server {
    listen 80;
    server_name notareal.com.net.org;
    location /media {
        root /home/www/projectroot;
    }
    location / {
        fastcgi_pass 127.0.0.1:8080;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
    }
}
server {
    listen 443;
    ssl on;
    ssl_certificate /usr/local/nginx/ssl/server.crt;
    ssl_certificate_key /usr/local/nginx/ssl/server.key;
    keepalive_timeout 70;
    server_name notareal.com.net.org;
    location /media {
        root /home/www/projectroot;
    }
    location / {
        fastcgi_pass 127.0.0.1:8080;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param HTTP_X_HTTPS on;
        fastcgi_pass_header Authorization;
        fastcgi_intercept_errors off;
    }
}

The magic line is fastcgi_param HTTP_X_HTTPS on; now we can modify our SSL redirection middleware to check for HTTP_X_HTTPS instead of HTTP_X_FORWARDED_SSL (or you could use HTTP_X_FORWARDED_SSL if you wanted, just change the nginx.conf)

And it all works well!




[ #117 ] Build nginx from Source on NetBSD 5.0 Permalink

nginx, NetBSD Added a year and a bit ago and last edited about two months ago

Here's my configure line:

./configure --prefix=/usr/local/nginx --with-pcre=/full/path/to/pcre/src --with-http_ssl_module



(Nothing Older) ... (Nothing Newer)

Colophon

Django Python 960.gs Git Vim NetBSD Nginx

The Author

This is the blog of Brad Willis, a software engineer living in Brisbane.

Meta

Help
Latest entries

*BSD Agile Apache Apple apt Athletics Best-Practice Censorship Comedy Cool Crosswords Deployment Django English Exim Firefox Git Hardcore Health irssi Javascript Jira Languages Linux Makefile Mathematics Mobile Broadband Mutt MySQL NetBSD nginx Nokia OpenVZ OSX Perl Privacy Python Rant Requirements rsync Ruby Shell Slackware SQL SQLite SSH Standards Subversion Television Testing ThisBlog Vim VMWare (Fusion) VPN X zsh

Recent Entries

Checking for exceptions in doctests
Homer's Curling Speech
retry in Python
Vim Makefile tabs
Centos (or RH) IPTables
Converting ssh2 public keys to openssh
Vim comment hints
Context managers in Perl
Dish rotation
Git - fixing commit user
apt stuff
Using shell variables in AWK
Linux - Too many open files
Tell gvim to save and quit... remotely
Vim - automatically remove whitespace at EOL
Python - relative paths from within modules
TV Aspect Ratios
Git - Which commits are in your branch only?
Subversion setup cheat sheet
Force detach a screen session
Modify sudo's use of environment variables
Install all Perl modules
Mutt - delete old messages
OpenVZ VPS and swap space
fail2ban on NetBSD for ssh
NetBSD - Using sup
Python - testing for a sys.exit
Python Best Practice Link Dump
Python script names
Perl - Using an expensive module
Speed of git clone
Perl Modules with Custom Prefix
Perl: tr vs. s
Brilliant sysadmin Reference
Why is GRUB better than LILO?
Why is swap space important?
Perldoc Output
Git's Index
Jira Project Keys
Git GUI

Links

ChoppingBoard, DaveMisc, Project365, RageQuit