Добрый день.
Есть сайт на битриксе под управлением nginx.
Так вот, не могу добиться что бы по несуществующим картинкам у сайта была отдача 404 ошибки от самого nginx.
Сейчас отдача 500 ошибка вылазиет по несуществующим картинкам..
try_files $uri =404; пробовал добавлять в локейшен с картинками, не фига не помогает.
location ~ /upload/.+\.(jpg|jpeg|png|webp) - проксируется на ресайз кратинок скриптом lua.
server {
...
...
...
server_name test.test.ru;
access_log /var/log/nginx/access_test.log;
error_log /var/log/nginx/error_test.log error;
root /usr/local/www/test/test.test.ru;
index index.html index.php;
include /usr/local/etc/nginx/redirect_04032021;
if ($request_uri ~ "^(/(?!personal|search|auth|bitrix).*)index\.(?:php$|html)") {
return 301 $1;
}
if (!-e $request_filename) {
rewrite ^(?!.*\.webp$)(.*)$ /bitrix/urlrewrite.php last;
}
location ^~ /.well-known/ {
root /usr/local/www/cert/;
}
location / {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
root /usr/local/www/test/test.test.ru;
}
location ~ \.php$ {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
fastcgi_pass unix:/tmp/test.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/test/test.test.ru/$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f www@test.test.ru";
if (!-f $request_filename) {
rewrite ^(.*)$ /404.php last;
}
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
add_header Access-Control-Allow-Origin *;
}
location ^~ /bitrix/admin/ {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
location ~ \.php$ {
fastcgi_pass unix:/tmp/test.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f www@test.test.ru";
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_ignore_client_abort off;
}
}
location ~ /upload/.+\.(jpg|jpeg|png|webp) {
proxy_buffers 8 2m;
proxy_buffer_size 10m;
proxy_busy_buffers_size 10m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_passhttp://127.0.3.4:8083 ;
}
location ~* \.(swf|zip|rar|arj|cab|exe|dll|ico|gif|bmp|mp3|avi|mov|mpg|mpeg|txt|amr|mmf|wml|wbmp|mid|midi|3gp)$ {
error_page 404 /404.html;
expires 30d;
charset utf-8;
source_charset utf-8;
access_log off;
}
location ~* ^/(upload|bitrix/images|bitrix/tmp) {
expires 30d;
access_log off;
}
location = /404.html {
access_log off ;
}
location ~ (/\.ht|/bitrix/modules|bitrix/managed_cache|bitrix/local_cache|bitrix/stack_cache|/upload/support/not_image|/bitrix/php_interface) {
deny all;
access_log off;
}
location ~* ^/upload/1c_[^/]+/ { deny all; }
location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
location ~* ^/bitrix/html_pages/\.enabled { deny all; }
location ^~ /upload/support/not_image { internal; }
location ~ /.svn/ {
deny all;
access_log off;
}
}
Есть сайт на битриксе под управлением nginx.
Так вот, не могу добиться что бы по несуществующим картинкам у сайта была отдача 404 ошибки от самого nginx.
Сейчас отдача 500 ошибка вылазиет по несуществующим картинкам..
try_files $uri =404; пробовал добавлять в локейшен с картинками, не фига не помогает.
location ~ /upload/.+\.(jpg|jpeg|png|webp) - проксируется на ресайз кратинок скриптом lua.
server {
...
...
...
server_name test.test.ru;
access_log /var/log/nginx/access_test.log;
error_log /var/log/nginx/error_test.log error;
root /usr/local/www/test/test.test.ru;
index index.html index.php;
include /usr/local/etc/nginx/redirect_04032021;
if ($request_uri ~ "^(/(?!personal|search|auth|bitrix).*)index\.(?:php$|html)") {
return 301 $1;
}
if (!-e $request_filename) {
rewrite ^(?!.*\.webp$)(.*)$ /bitrix/urlrewrite.php last;
}
location ^~ /.well-known/ {
root /usr/local/www/cert/;
}
location / {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
root /usr/local/www/test/test.test.ru;
}
location ~ \.php$ {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
fastcgi_pass unix:/tmp/test.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/test/test.test.ru/$fastcgi_script_name;
include fastcgi_params;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f www@test.test.ru";
if (!-f $request_filename) {
rewrite ^(.*)$ /404.php last;
}
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
add_header Access-Control-Allow-Origin *;
}
location ^~ /bitrix/admin/ {
index index.php;
satisfy any;
allow 7.2.0.7;
deny all;
auth_basic "closed site";
auth_basic_user_file /usr/local/.htpasswd;
location ~ \.php$ {
fastcgi_pass unix:/tmp/test.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f www@test.test.ru";
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_ignore_client_abort off;
}
}
location ~ /upload/.+\.(jpg|jpeg|png|webp) {
proxy_buffers 8 2m;
proxy_buffer_size 10m;
proxy_busy_buffers_size 10m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass
}
location ~* \.(swf|zip|rar|arj|cab|exe|dll|ico|gif|bmp|mp3|avi|mov|mpg|mpeg|txt|amr|mmf|wml|wbmp|mid|midi|3gp)$ {
error_page 404 /404.html;
expires 30d;
charset utf-8;
source_charset utf-8;
access_log off;
}
location ~* ^/(upload|bitrix/images|bitrix/tmp) {
expires 30d;
access_log off;
}
location = /404.html {
access_log off ;
}
location ~ (/\.ht|/bitrix/modules|bitrix/managed_cache|bitrix/local_cache|bitrix/stack_cache|/upload/support/not_image|/bitrix/php_interface) {
deny all;
access_log off;
}
location ~* ^/upload/1c_[^/]+/ { deny all; }
location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
location ~* ^/bitrix/html_pages/\.enabled { deny all; }
location ^~ /upload/support/not_image { internal; }
location ~ /.svn/ {
deny all;
access_log off;
}
}