POST not allowed (was Re: Location problems)
Igor Clark
igor at pokelondon.com
Mon Mar 10 13:51:23 MSK 2008
Ah, OK. I guess that means I can't use this configuration then, as I
need to have POST working under /admin.
However I need to IP-restrict /admin, so the previous version I was
using is apparently no good either, so it seems I'm stuck.
Thanks for your help though, I wouldn't have got this far without it.
Do you have a rough idea when 0.6.27 will be?
Will I need to make significant config changes to migrate from 0.5.35?
cheers,
Igor
On 10 Mar 2008, at 10:28, Igor Sysoev wrote:
> On Mon, Mar 10, 2008 at 10:05:17AM +0000, Igor Clark wrote:
>
>> 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?
>
> The patch. It will be included in 0.6.27.
>
>> 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
>>
>>
>>
>>
>>
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
> <patch.named.method>
--
Igor Clark // POKE // 10 Redchurch Street // E2 7DD // +44 (0)20 7749
5355 // www.pokelondon.com
More information about the nginx
mailing list