SSL, Django, and Nginx

I am in the process of setting up the fair’s website to handle ticket orders and needed to use SSL to make everything secure. So I bought the SSL certificate and set it up and all is well and dandy except for the fact that even though you are going to https://www.clearfieldcountyfair.com, django/apache only see the http request from the nginx load balancer/reverse proxy so django does not think the request is secure.

To enable this to work I had to make a tiny modification to my nginx config and wsgi application handler.

I added the following line to my proxy config in nginx:
proxy_set_header X-Url-Scheme $scheme;

I also modified the mod_wsgi application handler script as follows:
import os, sys
sys.path.append(’/usr/local/django’)
os.environ['DJANGO_SETTINGS_MODULE'] = ‘mysite.settings’

import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()

def application(environ, start_response):
environ['wsgi.url_scheme'] = environ.get(’HTTP_X_URL_SCHEME’, ‘http’)
return _application(environ, start_response)

Skirbit

I have added skirbit to the sidebar of my blog. Skirbit allows readers to make suggestions on things for me to write about since I have been slacking in the blogging department.

So if you want me to write about something, feel free to leave a suggestion.

– Jason

Setting up Django

Here is a short little guide that I have been using to setup django on my local machine for development as well as on my server. This guide pretty much comes straight from this screencast. Feel free to watch that great screencast on getting started with django or you can follow the brief guide below.

First create a pylink script which contains the following code somewhere on your $PATH. I usually create a bin directory in my home folder in which I place various scripts such as these by adding the following line to my .bashrc:

export PATH=~/bin:$PATH

2 line pylink script:

#!/bin/bash
ln -s `pwd`/$1 `python -c "from distutils.sysconfig import >>
get_python_lib; print get_python_lib()"`/$1

Create a python directory in your home directory and go into that directory then wget the the latest stable version of Django, in this case, Django 1.0.2…

wget http://www.djangoproject.com/download/1.0.2/tarball/
tar xzvf Django-1.0.2-final.tar.gz
cd Django-1.0.2-final

Use the pylink script to setup django

sudo pylink django

We will also want to be able to access the django-admin.py script from anywhere as well so we will want to add that to our path.

cd ~/python/Django-1.0.2-final/django/bin/
ln -s `pwd`/* ~/bin/

You should now be able to import django from within python!

Planned Maintenance Complete

I have successfully migrated the blog over to the new server.  If you run into any problems, please let me know.  You may still experience a few hiccups here and there as I tweak the new server configuration a bit more.  Sorry for any inconvenience.

Now off to bed as I am feeling well enough to head into work tomorrow.

– Jason

Planned Maintenance

I am moving the server that emerick.org runs on over to another server (still with slicehost though!).  This move is mostly for reconfiguring the server to handle django projects that I will be developing and deploying here in the very near future.  However, during this move, you may experience some outages of emerick.org.  I have already moved some other domains such as bbrtm.org over to the new server.  I will try to make the move as smooth as possible but of course there could always be issues.  I will do another post when the move is complete and everything is on the new server…

Thanks for your patience.

– Jason

First post! (of 2009)

Happy New Year everyone!

Hopefully everyone elses start to 2009 has been better than mine. I have been sick for the past week. Hopefully I will be better by Monday.

– Jason

Happy Holidays

Just wanted to say happy holidays to everyone!

– Jason

Invalid FORMATETC structure

I have ran into this issue a few times while working on an ASP.NET project when using ASP.NET AJAX community control toolkit and Telerik’s ASP.NET AJAX RadControls.  There seem to be several solutions out there to this common problem, but the one I found to work is quite simple.

Before adding a control to your page from the toolbox (which would give you the very helpful error above), simply make sure your project contains a reference to the correct DLL file and build the project after adding the new reference DLL file.

- Jason

Happy Thanksgiving!

I know I haven’t posted too much lately but I have been pretty busy with other things…  Maybe things will change with the new year…

Hope everyone had a happy thanksgiving!

- Jason

BBRTM 0.2

BBRTM is back!  I finally got around to working on BBRTM again and made a few updates.  This go around has been mostly back-end stuff that will support all future features.

For starters, I have changed the authentication process when you start up BBRTM for the first time.  Instead of just sending you to the RTM login page, I know take you through a step by step wizard to help you get authenticated.  Hopefully that will help new users get authenticated and reduce frustration. Embedded below is a little video screencast that covers the authentication process.


BBRTM Authentication Process from Jason Emerick on Vimeo.

(WMV download)

The next new thing is an options screen.  In the options screen there is only 1 setting for your connection mode (auto, BES, BIS, and TCP).  There is also a menu option for clearing your authentication token which would require you to re-authenticate BBRTM.

Another big backend change is threaded network connections.  By putting the network connections in a separate thread, it will no longer cause your BlackBerry to freeze while it loads data or makes a network request.  This should hopefully make the user experience much more smooth.  When BBRTM is loading you will see a screen like the one below.

In addition to the options menu item from the home screen, there are three other menu items.  The first one is refresh tasks which does exactly that, refreshes the task list.  Next is the About which displays a simple about screen.  Finally, there is a show all tasks menu item which will does as it says as well, it will display all of your tasks.

While you are viewing your task lists, you can also complete, delete and postpone them but the UI doesn’t refresh for all operations unless you refresh or restart BBRTM.  That is something I am working on and will be improving…

In addition to completeing, deleting, and postponing tasks, you can now view the details of a task such as notes and tags and other such things, just click on a task and it will take you to the detail screen.  You can’t edit or add tasks just yet, that is coming soon though…  That is my goal for this upcoming week and hopefully there will be another release next weekend.


I am sure there are a couple bugs or typos, so if you find any, just send me an email and I will look into it…

You can download or OTA install BBRTM v2.0 from http://bbrtm.org/ota/

note: i have moved the install files to the ota directory as I plan on creating a proper website for BBRTM in the near future so stay tuned for that as well…

Jason

Next Page »