From 7dae84f0027945bac29b45b63fdc0f795a5a813a Mon Sep 17 00:00:00 2001 From: Merlin Date: Fri, 4 Jun 2010 01:48:44 +0800 Subject: [PATCH] Enhanced the nginx deployment subsection of the documentation with working examples. 'tricky' was changed to 'different' to offer a more neutral tone. 'some' was changed to 'no' and 'not properly' swapped with 'by default' to explain the difference. Configuration allows for static serving of media alongside a FastCGI application in a clean declarative manner. Tested on nginx 0.7.x and 0.8.x --- docs/deploying/fastcgi.rst | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/docs/deploying/fastcgi.rst b/docs/deploying/fastcgi.rst index 7949cca4..a29664e8 100644 --- a/docs/deploying/fastcgi.rst +++ b/docs/deploying/fastcgi.rst @@ -73,26 +73,27 @@ root. Configuring nginx ----------------- -Installing FastCGI applications on nginx is a bit tricky because by default -some FastCGI parameters are not properly forwarded. +Installing FastCGI applications on nginx is a bit different because by default +no FastCGI parameters are forwarded. -A basic FastCGI configuration for nginx looks like this:: +A basic flask FastCGI configuration for nginx looks like this:: - location /yourapplication/ { + location = /yourapplication { rewrite ^ /yourapplication/ last; } + location /yourapplication { try_files $uri @yourapplication; } + location @yourapplication { include fastcgi_params; - if ($uri ~ ^/yourapplication/(.*)?) { - set $path_url $1; - } - fastcgi_param PATH_INFO $path_url; - fastcgi_param SCRIPT_NAME /yourapplication; + fastcgi_split_path_info ^(/yourapplication)(.*)$; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_pass unix:/tmp/yourapplication-fcgi.sock; } This configuration binds the application to `/yourapplication`. If you want -to have it in the URL root it's a bit easier because you don't have to figure +to have it in the URL root it's a bit simpler because you don't have to figure out how to calculate `PATH_INFO` and `SCRIPT_NAME`:: - location /yourapplication/ { + location / { try_files $uri @yourapplication; } + location @yourapplication { include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param SCRIPT_NAME "";