Работа над контейнером docker
Изменения в конфигах nginx Добавил привязку сервисов к 1 адресу
This commit is contained in:
@@ -8,7 +8,7 @@ server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /var/www/public;
|
||||
root /var/www/html/public;
|
||||
index index.php index.html;
|
||||
|
||||
# ========== ОСНОВНЫЕ НАСТРОЙКИ БЕЗОПАСНОСТИ ==========
|
||||
@@ -35,8 +35,8 @@ server {
|
||||
|
||||
location ~ \.php$ {
|
||||
# Дефолтные лимиты для всех PHP запросов
|
||||
limit_req zone=req_limit_per_ip burst=30 delay=15;
|
||||
limit_conn conn_limit_per_ip 30;
|
||||
limit_req zone=req_limit_per_ip burst=100 delay=15;
|
||||
limit_conn conn_limit_per_ip 60;
|
||||
|
||||
try_files $uri =404;
|
||||
|
||||
@@ -60,6 +60,43 @@ server {
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
}
|
||||
|
||||
# ========== REVERB (WEBSOCKET) ==========
|
||||
# Клиент бьёт в /app/{key} (WS), серверный broadcast — в /apps/{id}/... (REST).
|
||||
# Оба идут на тот же домен/порт, что и само приложение.
|
||||
|
||||
location /app/ {
|
||||
proxy_pass http://reverb:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Scheme $scheme;
|
||||
proxy_set_header SERVER_PORT $server_port;
|
||||
proxy_set_header REMOTE_ADDR $remote_addr;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
|
||||
location /apps/ {
|
||||
proxy_pass http://reverb:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# ========== Sentry ==========
|
||||
location /sentry/ {
|
||||
proxy_pass http://10.32.0.213:50/;
|
||||
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_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# ========== ОСНОВНОЙ LOCATION ==========
|
||||
|
||||
location / {
|
||||
|
||||
16
docker/entrypoint.sh
Normal file
16
docker/entrypoint.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
# Исправляем владельца и права на storage (включая логи) при каждом запуске
|
||||
if [ -d /var/www/html/storage ]; then
|
||||
mkdir -p /var/www/html/storage/logs/supervisor /var/www/html/storage/logs/nginx
|
||||
chown -R application:application /var/www/html/storage
|
||||
chmod -R 775 /var/www/html/storage
|
||||
fi
|
||||
|
||||
# Если переданы аргументы – выполняем их, иначе запускаем supervisord
|
||||
if [ $# -eq 0 ]; then
|
||||
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
|
||||
else
|
||||
exec "$@"
|
||||
fi
|
||||
@@ -1,3 +1,4 @@
|
||||
user application application;
|
||||
worker_processes auto;
|
||||
worker_rlimit_nofile 65535;
|
||||
|
||||
@@ -13,7 +14,13 @@ events {
|
||||
|
||||
http {
|
||||
limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
|
||||
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=10r/s;
|
||||
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=50r/s;
|
||||
|
||||
# Для проксирования WebSocket (Reverb) через тот же домен/порт.
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
@@ -43,8 +50,8 @@ http {
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss
|
||||
application/atom+xml image/svg+xml;
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/www/html/storage/logs/nginx/access.log;
|
||||
error_log /var/www/html/storage/logs/nginx/error.log;
|
||||
|
||||
limit_req_status 429;
|
||||
limit_conn_status 429;
|
||||
|
||||
13
docker/php-fpm-pool.conf
Normal file
13
docker/php-fpm-pool.conf
Normal file
@@ -0,0 +1,13 @@
|
||||
[www]
|
||||
user = application
|
||||
group = application
|
||||
listen = 9000
|
||||
; или listen = /var/run/php/php8.3-fpm.sock
|
||||
listen.owner = application
|
||||
listen.group = application
|
||||
listen.mode = 0660
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
@@ -1,6 +1,6 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
logfile=/var/log/supervisor/supervisor.log
|
||||
logfile=/var/www/html/storage/logs/supervisor/supervisor.log
|
||||
logfile_maxbytes=50MB
|
||||
logfile_backups=3
|
||||
|
||||
@@ -9,8 +9,8 @@ command=/usr/local/sbin/php-fpm -F
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=5
|
||||
stdout_logfile=/var/log/supervisor/php-fpm.log
|
||||
stderr_logfile=/var/log/supervisor/php-fpm_err.log
|
||||
stdout_logfile=/var/www/html/storage/logs/supervisor/php-fpm.log
|
||||
stderr_logfile=/var/www/html/storage/logs/supervisor/php-fpm_err.log
|
||||
logfile_maxbytes=50MB
|
||||
logfile_backups=3
|
||||
|
||||
@@ -19,7 +19,5 @@ command=/usr/sbin/nginx -g "daemon off;"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
priority=10
|
||||
stdout_logfile=/var/log/supervisor/nginx.log
|
||||
stderr_logfile=/var/log/supervisor/nginx_err.log
|
||||
logfile_maxbytes=50MB
|
||||
logfile_backups=3
|
||||
|
||||
Reference in New Issue
Block a user