@realmen80

Nginx, php-fpm ошибка 404 при открытии файла, как исправить?

На сайте установил модуль который генерирует xml файл с товарами для Google remarketing.

В модуле указана ссылка по которой после генерации можно увидеть файл, вот так - https://site.ua/ab__pfe_4_xml-feed.xml

Но после генерации, при попытке открыть файл - получаю 404 ошибку на сайте…

В документации разработчиков модуля - https://docs.cs-cart.abt.team/ru/ab__product_feed_...написано:

Так как файлы выгрузок не находятся в корне сайта, nginx должен проксировать такие запросы на сайт (в обход стандартной отдачи статических файлов). Вы можете для этого использовать прямую ссылку на файл:
location = /ab__pfe_1_test.xml
Но, чтобы не создавать отдельное правило для каждой выгрузки, лучше использовать следующую маску:
location ~ ^/ab__pfe_[0-9]+_.*$
Если при запросе файла сайта Вы получаете 404 ошибку сервера (не путать с 404 страницей сайта), значит проксирование настроено некорректно. Нужно настроить проксирование на сервере корректно, чтобы файл открывался.

Сервер работает на Nginx+PHP-FPM. Версия PHP - 7.1.30.

Команда uname -a выдает такую информацию:
Linux server96.site.ua 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux


Почитав форумы, если я правильно понимаю, то нужно какое-то правило прописать в файле default.conf, чтобы файл начал открываться....

У меня есть два файла default.conf и site.ua.conf. Прикрепил оба.

Подскажите, пожалуйста, что я должен прописать и в каком файле, чтобы файл открывался корректно. Заранее благодарен за помощь

site.ua.conf
spoiler
server {
     listen  80;
     listen  443 ssl;

    server_name *.site.ua;
    return 301 https://site.ua$request_uri;
    rewrite ^(.*)$ https://site.ua permanent;
#   rewrite ^([^.\?]*[^/])$ $1/ permanent;

    ############################################################################

       ssl                         on;
       ssl_certificate             /etc/letsencrypt/live/site.ua/fullchain.pem;
       ssl_certificate_key         /etc/letsencrypt/live/site.ua/privkey.pem;
       include                     xtra/ssl.conf;

    ############################################################################

}

server {
    listen  80;
    listen  443 ssl;
    
    server_name site.ua;
    server_name www.site.ua;
    rewrite ^/(.*)/$ /$1 permanent;
#   server_name *.site.ua;    
#   rewrite ^([^.\?]*[^/])$ $1/ permanent;
   
    
    ############################################################################

    charset utf-8;

    ############################################################################

    access_log  /var/log/nginx/site.ua/access.log extended;
    error_log   /var/log/nginx/site.ua/error.log;

    ############################################################################

    include xtra/error-40X.conf;
    include xtra/error-50X.conf;

    ############################################################################

	ssl                         on;
	ssl_certificate             /etc/letsencrypt/live/site.ua/fullchain.pem;
	ssl_certificate_key         /etc/letsencrypt/live/site.ua/privkey.pem;
	include                     xtra/ssl.conf;

    ############################################################################

    set $root "/var/www/html/site.com_prod";
    root $root;
   
    include sites-available/locations.conf; 
}


################################################################################


default.conf

spoiler
server {
  listen      80 default_server;
  server_name  _; 

  charset utf-8;

  include xtra/error-40X.conf;
  include xtra/error-50X.conf;

  location / {
	return 404;
  }

  location /pma/ {
        alias /usr/share/phpmyadmin/;
        index index.php;

  	location ~ \.php$ {
 		fastcgi_pass www;
        	fastcgi_index index.php;
        	fastcgi_read_timeout 3600;
		include xtra/fastcgi_params.conf;
   		fastcgi_param SCRIPT_FILENAME  $request_filename;
  	}
  
  	location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    		access_log    off;
    		log_not_found    off;
    		expires 1M;
  	}	
  }
   
 location /pma/setup/ {
	return 404;
 }
 location /pma/libraries/ {
	return 404;
 }

 location /postfixadmin/ {
        alias /var/www/html/postfixadmin/;
        index index.php;

        location ~ \.php$ {
                fastcgi_pass www;
                fastcgi_index index.php;
                fastcgi_read_timeout 3600;
                include xtra/fastcgi_params.conf;
                fastcgi_param SCRIPT_FILENAME  $request_filename;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                access_log    off;
                log_not_found    off;
                expires 1M;
        }
 }
}


locations.conf
spoiler
error_page 598 = @backend;

    ############################################################################

    location @backend {
        

try_files $uri $uri/ =404;
        fastcgi_pass www;
        fastcgi_index index.php;
        fastcgi_read_timeout 360;
        include xtra/fastcgi_params.conf;
        # include xtra/fastcgi_params_ssl.conf;
    }

location ^~ /images/detailed/ {
  location ~* \.(gif|png|jpeg|jpg)$ {
    if ($request_uri !~ "rz=1") {
      rewrite .* /index.php?dispatch=watermark.create$args last;
    }
  }
}

location ^~ /images/product/ {
  location ~* \.(gif|png|jpeg|jpg)$ {
    if ($request_uri !~ "rz=1") {
      rewrite .* /index.php?dispatch=watermark.create$args last;
    }
  }
}

location ^~ /images/category/ {
  location ~* \.(gif|png|jpeg|jpg)$ {
    if ($request_uri !~ "rz=1") {
      rewrite .* /index.php?dispatch=watermark.create$args last;
    }
  }
}

location ^~ /images/gallery/ {
  location ~* \.(gif|png|jpeg|jpg)$ {
    if ($request_uri !~ "rz=1") {
      rewrite .* /index.php?dispatch=watermark.create$args last;
    }
  }
}

    location @fallback {
        rewrite  ^(.*)$ /index.php?$args last;
    }

    location @statics {
        rewrite ^/([a-z0-9-\.]+)/(.*)$ /$2 break;
        access_log off;
        rewrite_log off;
        expires max;
        add_header Cache-Control public;
        add_header Access-Control-Allow-Origin *;
    }

    ############################################################################

    location / {
        index  index.php index.html index.htm;

        rewrite ^/api/(.*)$ /api.php?_d=$1&ajax_custom=1&$args last;
        try_files $uri $uri/ @fallback;

        location ^~ /robots.txt {
            try_files $uri @fallback;
        }

        location ~* \.(jpeg|ico|jpg|gif|png|css|js|pdf|tar|wof|zip) {
            access_log off;
            try_files $uri @statics;
            expires max;
            add_header Access-Control-Allow-Origin *;
            add_header Cache-Control public;
        }

        location ~* \.([pP][hH][pP].?)$ {
           try_files $uri $uri/ /index.php;
           fastcgi_pass www;
           fastcgi_index index.php;
           fastcgi_read_timeout 360;
           include xtra/fastcgi_params.conf;

	   add_header Cache-Control no-store;
        }

        location ^~ /app/ {
            return 404;
            location = /app/addons/rus_exim_1c/exim_1c.php {
                return 598;
            }
        }

        location ^~ /app/payments/ {
            return 404;
            location ~ \.php$ {
                return 598;
            }
        }

        location ^~ /app/addons/paypal/payments/ {
            return 404;
            location ~ \.php$ {
                return 598;
            }
        }

        location ^~ /design/ {
            allow all;
            location ~* \.([tT][pP][lL]|[pP][hH][pP].?)$ {
                return 404;
            }
        }

        location ^~ /var/ {
            return 404;
            location ~* \.(js|css|png|jpeg|jpg|gz|xml|yml)$ {
                allow all;
                expires 1M;
                add_header Cache-Control public;
                add_header Access-Control-Allow-Origin *;
            }
        }

        location ^~ /var/themes_repository/ {
            allow all;
            location ~* \.([tT][pP][lL]|[pP][hH][pP].?)$ {
                return 404;
            }
        }

        location ^~ /images/ {
            allow all;
            location ~* \.([pP][hH][pP].?)$ {
                return 404;
            }
        }

         location = /init.php {
            return 404;
        }

        location ^~ /var/database/ {
            return 404;
        }

        location ~* \.([tT][pP][lL].?)$ {
            return 404;
        }

        location ~ /\.(ht|git) {
            return 404;
        }
    }
  • Вопрос задан
  • 215 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы