POST not allowed (was Re: Location problems)
Igor Clark
igor at pokelondon.com
Mon Mar 10 13:05:17 MSK 2008
Thanks Igor. I just tried this and it allows it through, but it
appears to the upstream as a GET. It needs to be a POST as it has
multipart/form-data. Any thoughts?
cheers
Igor
On 8 Mar 2008, at 20:06, Igor Sysoev wrote:
> On Thu, Mar 06, 2008 at 05:41:21PM +0000, Igor Clark wrote:
>
>> The following configuration is giving me 405 Not Allowed errors
>> when I
>> try to POST to any URI.
>>
>> I'm guessing that it thinks the URLs are static, but I don't know
>> why.
>
> Try to change
>
> - error_page 404 = @...;
> + error_page 404 405 = @...;
>
>> Example URI is /admin/clips/edit/63 - but I've tried posting to /
>> with
>> the same result.
>>
>> Nothing is written to the error_log, even on "info" or "notice",
>> though the 405 appears in access_log.
>>
>> I've tried it with fastcgi_intercept_errors and recursive_error_pages
>> both off, with the same result.
>>
>> Any ideas on how to fix it would be very welcome.
>> Thanks very much!
>> Igor
>>
>>
>> server {
>> listen 80;
>> server_name my.web.site;
>>
>> access_log /path/to/logs/access.log main;
>> error_log /path/to/logs/error.log info;
>>
>> root /path/to/public;
>>
>> # enable nginx to serve custom error pages
>> # on receiving HTTP error codes from back-end
>> fastcgi_intercept_errors on;
>> recursive_error_pages on;
>>
>> # show custom error pages
>> error_page 403 /403.html;
>> error_page 404 /404.html;
>> error_page 500 /500.html;
>>
>> # deny public access to frontend script
>> location /frontend.php {
>> internal;
>> }
>>
>> # deny public access to admin script
>> location /admin.php {
>> internal;
>> }
>>
>> # serve standard files standardly.
>> # if file not found, fall back to php app using (rewrite if
>> neceessary) URL
>> location / {
>> rewrite ^/$
>> /financethemes/index;
>> rewrite ^/speakers/((?!video).+)/?$
>> /speakers/video/$1;
>> rewrite ^/financethemes/((?!video|index).+)/?$
>> /financethemes/video/ $1;
>> rewrite ^/transcripts/(speaker|theme)/(.+)/?$
>> /transcripts/view/ $1/$2;
>>
>> error_page 404 = @phpapp;
>> }
>
> You do not need these rewrite's, use location's.
> The configuration is bigger, but it's much clearer and so it's
> scaleable:
> you can easy add new locations without being afraid to break some
> rewrite.
>
> However, you may need to use some rewrite's in these locations if
> you need
> to rewrite URI to pass into "location ~ \.flv$" with changed URI to
> match
> common root.
>
> location = / {
> index index;
> root /path/to/public/financethemes;
> error_page 404 = @phpapp;
> }
>
> location / {
> error_page 404 = @phpapp;
> }
>
> location /speakers/ {
> alias /path/to/public/speakers/video/;
> error_page 404 = @phpapp;
> }
>
> location /speakers/video/ {
> error_page 404 = @phpapp;
> }
>
> location /financethemes/ {
> alias /path/to/public/financethemes/video/;
> error_page 404 = @phpapp;
> }
>
> location /financethemes/video/ {
> error_page 404 = @phpapp;
> }
>
> location /transcripts/theme/ {
> alias /path/to/public/transcripts/view/theme/;
> error_page 404 = @phpapp;
> }
>
> location /transcripts/speaker/ {
> alias /path/to/public/transcripts/view/speaker/;
> error_page 404 = @phpapp;
> }
>
>> # serve not found urls using /frontend.php script
>> location @phpapp {
>> fastcgi_pass 127.0.0.1:8888;
>> fastcgi_param SCRIPT_FILENAME
>> $document_root/frontend.php;
>> fastcgi_param QUERY_STRING CONTROL_PATH=$uri;
>> include conf/fastcgi_params
>> }
>>
>> # IP-restrict anything under /admin
>> location /admin {
>> allow 1.2.3.4;
>> deny all;
>>
>> rewrite ^/admin/?$ /admin/clips/all;
>>
>> error_page 404 = @adminapp;
>> }
>>
>> # serve admin app using /admin.php;
>> location @adminapp {
>> fastcgi_pass 127.0.0.1:8888;
>> fastcgi_param SCRIPT_FILENAME
>> $document_root/admin.php;
>> fastcgi_param QUERY_STRING CONTROL_PATH=$uri;
>> include conf/fastcgi_params;
>> }
>>
>> # use the FLV module for flv files
>> location ~ \.flv$ {
>> flv;
>> }
>>
>> # deny access to .svn dirs
>> location ~ /\.svn {
>> deny all;
>> }
>> }
>>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
--
Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749
5355 // www.pokelondon.com
More information about the nginx
mailing list