小编Mic*_*ill的帖子

Nginx 禁止使用 Magento 在上传目录中执行 PHP

我很难让 nginx 在 magento 安装的上传目录中停止执行 PHP。我尝试了许多指令组合,当 *.php 在该目录中匹配时应该发送 503 或类似的指令,但我仍然可以在那里执行 PHP。当然,代码解决方案是防止上传 .php 文件,但我不明白如何从 nginx 的角度阻止执行。

map $http_x_ssl_offloaded $fastcgi_https {
  default off;
  on      on;
}


server {
    listen       80;
    server_name  store.xxxx.com;
    root         /var/www/store.xxxx.com;

    #charset koi8-r;


    #access_log  /var/log/nginx/store.xxxx.com-access.log  main;
    access_log  /var/log/nginx/store.xxxx.com-access.log;
error_log   /var/log/nginx/store.xxxx.com-error.log;


gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 9;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;


 location / {
    index index.html index.php;
    try_files $uri $uri @handler;
    expires 30d; ## Assume all files are cachable
}

## Location …
Run Code Online (Sandbox Code Playgroud)

php centos nginx magento

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

centos ×1

magento ×1

nginx ×1

php ×1