Nginx 405不允许指定'.php'文件 [英] Nginx 405 not allowed to specific '.php'-file

查看:293
本文介绍了Nginx 405不允许指定'.php'文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Nginx的问题。我只是在学习它,所以它不知道解决这个问题。

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

我的一个插件是试图POST到一个特定的网址,以PHP '-延期。
该文件不在文件夹根目录中的位置:' web 。但在目录:
web / plugins / moxiemanager / api.php 。但我总是收到405。

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?

我的Nginx配置:

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;

}

推荐答案

这可能不是最好的方法,我仍然找到我的方式与nginx,但它工作了我刚刚。

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.

我重复我现有的位置块为app.php覆盖moxia脚本,所以对我来说添加这个工作...

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;
}

覆盖以moxiemanager / api.php结尾的网址。我不是100%确定这样做的安全影响,虽然。

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

这篇关于Nginx 405不允许指定'.php'文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆