listen 80 deferred reuseport default;
listen [::]:80 deferred reuseport default;
server_name bitrix;
charset utf-8;
root /var/www/bitrix;
index index.php index.html bitrixsetup.php;
access_log /var/log/nginx/bitrix-access.log;
error_log /var/log/nginx/bitrix-error.log;
# bitrix recommendation, respect server's mime-type and don't try to guess it
add_header X-Content-Type-Options nosniff;
if (!-e $request_filename) {
rewrite ^(.*)$ /bitrix/urlrewrite.php last;
}
# remove multiple slashes
# duplicated slashes sometimes will work and won't be rewritten, fixing it in this configuration is tricky
rewrite ^([^.]*?\/)\/+(.*)$ $1$2 permanent;
# redirect index.php to page without it
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
location / {
if (-f /var/www/bitrix/index.php) {
root /var/www/bitrix;
break;
}
if (-f /var/www/bitrix/bitrixsetup.php) {
root /var/www/bitrix;
break;
}
try_files $uri $uri/ @bitrix;
root /var/www/html;
}
location @bitrix {
fastcgi_pass php-upstream;
include fastcgi_params;
# make SERVER_NAME behave same as HTTP_HOST
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
}
location = /api {
include fastcgi_params;
fastcgi_pass php-upstream;
include fastcgi_params;
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root/version2/api/entry.php;
}
location = /restore.php {
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
# make SERVER_NAME behave same as HTTP_HOST
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location = /favicon.png {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off;
access_log off;
}
location ~ (/\.ht|/\.git|/\.gitignore|\.settings\.php|/composer|/bitrix/backup|/bitrix/updates|/bitrix/modules|/bitrix/php_interface|/bitrix/stack_cache|/bitrix/managed_cache|/bitrix/html_pages/\.|/upload/1c_exchange|local/modules|local/php_interface|/logs/) {
deny all;
}
# Internal location
location ^~ /upload/support/not_image { internal; }
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|eot|otf|ttf|woff|woff2)$ {
log_not_found off;
access_log off;
expires 30d;
add_header Cache-Control public;
# re-add security header
add_header X-Content-Type-Options nosniff;
}
# Disable access for non-static assets (not js and css) in cache location
location ~* ^/bitrix/cache { deny all; }
location ~ /upload/ {
client_body_buffer_size 1024m;
client_max_body_size 1024m;
}
location ~ \.php$ {
# redirect index.php to page without it
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
include fastcgi_params;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_send_timeout 21600;
fastcgi_read_timeout 21600;
# make SERVER_NAME behave same as HTTP_HOST
fastcgi_param SERVER_NAME $host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /404.html;
location /404.html {}
}
nginx -t покажет что не так
Обсуждают сегодня