project_start/conf/nginx/nginx_config_dev.conf

153 lines
4.6 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

server {
listen 8090;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/javascript;
client_max_body_size 1000M;
set $host_path "/var/www";
server_name localhost;
root $host_path/layouts;
set $bootstrap "index.html";
charset utf-8;
location / {
index index.html $bootstrap;
try_files $uri $uri/ /$bootstrap?$args;
}
# отключаем обработку запросов к несуществующим статичным файлам
location ~ \.(js|css|png|jpg|jpeg|gif|swf|ico|pdf|mov|fla|zip|rar|svg)$ {
try_files $uri =404;
}
}
server {
listen 80;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/javascript;
client_max_body_size 1000M;
error_log /var/log/nginx/debug.log debug;
set $host_path "/var/www";
server_name _;
root $host_path/html/standard_encode;
set $bootstrap "index.php";
charset utf-8;
location ^~ /xml_files/ {
# Запрещаем выполнение любых PHP-файлов
location ~ \.php$ {
return 404;
}
# Разрешаем отдачу статики (изображений, CSS, JS и т. д.)
try_files $uri =404;
}
location ~ ^/img/shop/(.*)$ {
# Проверяем существование файла
try_files $uri /front_img-handler.php?img=$1;
}
location ~ ^/img/vehicle-previews/(.*)$ {
# Проверяем существование файла
try_files $uri /dismantle_img-handler.php?img=362x266_$1;
}
location ~ ^/img/vehicle-original/(.*)$ {
# Проверяем существование файла
try_files $uri /dismantle_img-handler.php?img=1700x1250_$1;
}
location ~ ^/img/vehicle-big-previews/(.*)$ {
# Проверяем существование файла
try_files $uri /dismantle_img-handler.php?img=874x642_$1;
}
rewrite ^/img-prev/(.*)$ /img-handler.php?img=$1 last;
location / {
index index.html $bootstrap;
try_files $uri $uri/ /$bootstrap?$args;
# auth_basic "Restricted Content";
# auth_basic_user_file /home/passwd/.htpasswd;
}
# location ^~/api {
# auth_basic off;
# index index.html $bootstrap;
# try_files $uri $uri/ /$bootstrap?$args;
# }
# отключаем обработку запросов к несуществующим статичным файлам
location ~ \.(js|css|png|jpg|jpeg|gif|swf|ico|pdf|mov|fla|zip|rar|svg)$ {
try_files $uri =404;
}
# Кэширование изображений
location ~* \.(jpg|jpeg|png|gif|ico|webp)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
# Кэширование скриптов
location ~* \.(js)$ {
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
# Кэширование стилей
location ~* \.(css)$ {
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
# Кэширование шрифтов
location ~* \.(woff|woff2|ttf|eot|otf)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
rewrite ^/img-prev/(.*)$ /img-handler.php?img=$1 last;
# передаем PHP-скрипт серверу FastCGI, прослушивающему адрес 127.0.0.1:9000
location ~ \.php {
fastcgi_split_path_info ^(.+\.php)(.*)$;
# позволяем перехватывать запросы к несуществующим PHP-файлам
set $fsn /$bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
include /etc/nginx/fastcgi.conf;
#fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;
#fastcgi_param QUERY_STRING $query_string;
# PATH_INFO и PATH_TRANSLATED могут быть опущены, но стандарт RFC 3875 определяет для CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}
# не позволять nginx отдавать файлы, начинающиеся с точки (.htaccess, .svn, .git и прочие)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}