0

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"
helcim
  • 273
  • 2
  • 6
  • 13
  • I don't see any obvious issues with the configuration you've posted. I suspect the issue is going to be in your web application. – Michael Hampton Jun 08 '13 at 17:42
  • The application is running just fine under Apache. Is it possible that differences between php backends might be to blame? – helcim Jun 08 '13 at 17:46
  • Consider that nginx does not use .htaccess files. So it could be the case that under Apache a .htaccess was used to modify configuration of php and/or apache modules which are required by your application. – leepfrog Jun 08 '13 at 17:52
  • Do **NOT** use `location ~ \.php$ {`, it is insecure. See https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/ – NuclearPeon May 27 '14 at 01:33

1 Answers1

0

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

chrskly
  • 1,569
  • 12
  • 16
  • This link is dead. What was the "known issue"? – Michael Hampton Jan 16 '19 at 16:18
  • Pasting the contents below. Essentially, you can't POST to a static page. Although, looking at it now, I'm not sure why I thought it was relevant to the question asked. – chrskly Jan 25 '19 at 13:47
  • On Mon, Oct 08, 2007 at 12:15:58PM -0400, Jonathan Vanasco wrote: > I'm trying to POST a form to an html page -- there is no code ; i am > just faking a form flow for a client > > nginx gives me a "405 Not Allowed" on the post request ; i can get > the page fine > > is there a directive i can use to get around this ? No, as static page can not handle POST, so nginx return 405. There is workaround: error_page 405 = @405; location = @405 { root ...; } – chrskly Jan 25 '19 at 13:47