简体   繁体   中英

Nginx 405 not allowed to specific '.php'-file

I've got a problem with Nginx. I'm just learning it, so it don't know fix this issue.

One of my plugins is trying to POST to a specific url that ends with a 'PHP'-extension. The file isn't location in the root of the folder: ' web '. But in the directory: web/plugins/moxiemanager/api.php . But I'm always receiving a 405.

What do I have to change in the configurations?

Thanks in advance.

My Nginx configurations:

server {
   listen 80;
   server_name kevin.dev;
   root /var/www/html/kevin/web;

location / {
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /app.php/$1 last;
}

location ~ ^/(api|app|app_dev|config)\.php(/|$) {
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS off;
}

error_log /var/log/nginx/kevin_error.log;
access_log /var/log/nginx/kevin_access.log;

}

This may not be the best way to do it, I'm still finding my way with nginx, but it worked for me just now.

I duplicated my existing location block for app.php to cover the moxia script, so for me adding this did the job...

location ~ moxiemanager/api.php$ {
    fastcgi_pass   unix:/var/run/php5-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param SERVER_PORT 80;
    include        /etc/nginx/fastcgi_params;
}

that covers urls ending with moxiemanager/api.php. I'm not 100% sure of the security implications of doing it like this though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM