Загрузка файла WordPress 404 после настройки ALLOW_UNFILTERED_UPLOADS - PullRequest
0 голосов
/ 24 февраля 2019

У меня есть nginx с WordPress 5.1, и я позволил загружать файлы всех типов, установив в wp-config.php эту строку define( 'ALLOW_UNFILTERED_UPLOADS', true );.Теперь я могу загрузить все, что угодно, и все еще могу загружать «разрешенные» файлы, например изображения, но я не могу загрузить другие пользовательские файлы.Я получаю сообщение об ошибке 404, но из журнала nginx файл, к которому я пытаюсь получить доступ по ссылке, действительно существует по этому точному пути.

Пример ссылки: http://localhost/wp-content/uploads/2019/02/public.key Я получаю эту ссылку из диспетчера медиа в Wordpress.

nginx.conf:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

conf.d / default.conf:

server {
    listen 80 default_server;
    server_name _;
    root /var/www/html;

    client_max_body_size 4096m;

    index index.php;

    include global/restrictions.conf;
    include global/wordpress.conf;
}

global / sizes.conf:

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    try_files $uri /index.php?$args;
}

location ~ /\. {
    deny all;
}

location ~* /(?:uploads|files)/.*\.php$ {
    deny all;
}


location ~* wp-admin/includes { deny all; }
location ~* wp-includes/theme-compat/ { deny all; }
location ~* wp-includes/js/tinymce/langs/.*\.php { deny all; }
location /wp-content/ { internal; }
location /wp-includes/ { internal; }

location ~ /(\.|wp-config.php|readme.html|license.txt) { deny all; }

location ~ ~$ { access_log off; log_not_found off; deny all; }

global /wordpress.conf:

location / {
    try_files $uri $uri/ /index.php?$args;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

location ~* ^.+\.(eot|otf|woff|woff2|ttf|rss|atom|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
    access_log off; log_not_found off; expires max;
}

location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
}

location ~* \.(?:css|js)$ {
  expires 1y;
  access_log off;
  add_header Cache-Control "public";
}

location ~* \.(html)$ {
  expires 7d;
  access_log off;
  add_header Cache-Control "public";
}

location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf)$ {
expires 7d;
add_header Cache-Control "public, no-transform";
}

gzip on;
gzip_disable "msie6";

gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
        return 404;
    }
    # This is a robust solution for path info security issue and works with "cgi.fix_pathinfo = 1" in /etc/php.ini (default)

    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PHP_VALUE "upload_max_filesize=4096m
post_max_size=4096m";
    fastcgi_pass cake-web_wp:9000;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...