Nginx – What the 405 error may mean in nginx error log when migrating from Apache to nginx

apache-2.2fastcginginx

I am trying to migrate Topincs installation from Apache to nginx running on Debian Wheezy and using php-fmp. The only error I'm getting is

HTTP/1.1 405 Method Not Allowed

Would be grateful for any hint how to tackle this problem.

Here is my site configuration in /etc/nginx/sites-enabled/my-app

server {
    listen   80;
    server_name localhost;
    index index.php;
    root /home/my-app/topincs/docroot;
    fastcgi_intercept_errors on;




    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
                }

    location ~ nkm {
        fastcgi_param  TOPINCS_STORE nkm;
        try_files $uri $uri/ /index.php;
        }


    location ~ /\.[0-9]\.[0-9]+\.[0-9](beta\([0-9]+\))? {

        add_header Expires "Fri, 31 Dec 2020 23:59:59 GMT";
            add_header Cache-Control "public";
        }

    location /nkm { 
         rewrite ^/nkm/([3-9]\.[0-9]\.[0-9].*/(.core-topics|css|images|js|vendor|fonts).*)$ /nkm/$1; 
         rewrite ^/nkm((\.|/).*)$ /nkm/.topincs?request=$1; 
         }

    }

Here are original Apache conf files:

httpd.conf

RewriteEngine on
<Directory "/home/my-app/topincs/docroot">
    Order allow,deny
    Allow from all
    DirectoryIndex index.php
    AddType 'text/html; charset=UTF-8' .html
    DefaultType application/x-httpd-php
    php_value include_path "/home/my-app/topincs/php:/home/my-app/topincs/vendor/php"
    php_value default_charset "UTF-8"
    php_value magic_quotes_gpc "0"
    php_value max_execution_time "7200"
    php_value memory_limit "500M"
    php_value short_open_tag "0"
</Directory>

<Directory ~ "/home/my-app/topincs/docroot/[0-9]\.[0-9]+\.[0-9](beta\([0-9]+\))?">
    FileETag none
    Header set Expires "Fri, 31 Dec 2020 23:59:59 GMT"
    Header set Cache-control "public"
</Directory>

Include "/home/my-app/topincs/conf/*.httpd.conf"

The only other file in /home/my-app/topincs/conf/ is nkm.httpd.conf:

<LocationMatch ^/nkm/.*>
    SetEnv TOPINCS_STORE nkm
</LocationMatch>

#RewriteRule ^/nkm/test/(.*)$ /nkm/test/$1 [PT,E=TOPINCS_STORE:nkm]
RewriteRule ^/nkm/([3-9]\.[0-9]\.[0-9].*/(.core-topics|css|images|js|vendor|fonts).*)$ /nkm/$1 [PT,E=TOPINCS_STORE:nkm]
RewriteRule ^/nkm((\.|/).*)$ /nkm/.topincs?request=$1 [PT,L,QSA,E=TOPINCS_STORE:nkm]

Alias /nkm "/home/my-app/topincs/docroot"

and to default /etc/php5/fpm/pool.d/www.conf I added the following lines:

php_value[include_path]  = "/home/my-app/topincs/php:/home/my-app/topincs/vendor/php"
php_value[default_charset] = "UTF-8"
php_value[magic_quotes_gpc] = "0"
php_value[php_value max_execution_time] = "7200"
php_value[php_value memory_limit] = "500M"
php_value[php_value short_open_tag] = "0"

Best Answer

Are these requests POSTs? If so, this is a known issue. See here.