Piston + HTTP Authentication + mod_FastCGI

I’ve spent much more time than necessary on this issue, so if it can help someone, I’m posting a working config for Django Piston + Apache’s mod_fastcgi + HTTP Basic Authentication.

Works with :

  • Apache 2.0.63
  • Django 1.2.3
  • Piston 0.2.2

I’ve updated the default config file found on the official Django website:

FastCGIExternalServer /project/dir/mysite.fcgi -socket /project/dir/mysite.sock -pass-header Authorization

<VirtualHost 123.456.78.9>
ServerName servername.com
DocumentRoot /project/dir
Alias /media /project/dir/media
RewriteEngine On
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /mysite.fcgi/$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
</VirtualHost>

tl;dr: -pass-header Authorization and [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]

Advertisements

2 responses to “Piston + HTTP Authentication + mod_FastCGI

  1. Thank you very much!

    I was trying to figure out why my Apache 2.2 + mod_fastcgi + php-fpm was not working with basic authentication!

    Adding -pass-header Authorization to my FastCgiExternalServer config got it working!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s