Files
SERVER-API/nginx/nginx.conf
2025-10-28 01:39:22 +03:00

81 lines
2.5 KiB
Nginx Configuration File
Raw Permalink 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.
# Основные настройки Nginx
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"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# Upstream для PHP-FPM серверов
upstream php_fpm_v1 {
server php-fpm-v1:9000;
}
upstream php_fpm_v2 {
server php-fpm-v2:9000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
# API v1: фронт-контроллер index.php внутри контейнера php-fpm-v1
location ~ ^/api/v1(?:/|$) {
include fastcgi_params;
fastcgi_pass php_fpm_v1;
fastcgi_param SCRIPT_FILENAME /var/www/html/index.php;
fastcgi_param PHP_VALUE "upload_max_filesize=100M \n post_max_size=100M";
fastcgi_read_timeout 300;
}
# API v2: фронт-контроллер index.php внутри контейнера php-fpm-v2
location ~ ^/api/v2(?:/|$) {
include fastcgi_params;
fastcgi_pass php_fpm_v2;
fastcgi_param SCRIPT_FILENAME /var/www/html/index.php;
fastcgi_param PHP_VALUE "upload_max_filesize=100M \n post_max_size=100M";
fastcgi_read_timeout 300;
}
# Обслуживание статических файлов (если появятся)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Безопасность: скрываем служебные файлы
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ /README\.md$ {
deny all;
access_log off;
log_not_found off;
}
# Метрики Nginx: stub_status для экспорта
location /status {
stub_status;
access_log off;
# В DEV среде открыт; в PROD ограничить по IP/ACL
}
}
}