# nginx.conf # Конфигурация 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"'; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; # Настройки sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 50M; # Gzip сжатие gzip on; gzip_vary on; gzip_min_length 1024; gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json image/svg+xml; # Upstream для админки upstream morele_admin { server 127.0.0.1:5000; } server { listen 80; server_name your-domain.com www.your-domain.com; # Редирект на HTTPS (если используется) # return 301 https://$server_name$request_uri; # Раздача изображений location /images/ { alias /path/to/morele_parser/images/; # Кеширование expires 7d; add_header Cache-Control "public, immutable"; # Оптимизация location ~* \.(jpg|jpeg|png|webp)$ { add_header Vary Accept; try_files $uri $uri/ =404; } } # Раздача фидов location /feeds/ { alias /path/to/morele_parser/feeds/; # Только для авторизованных пользователей # auth_basic "Restricted Area"; # auth_basic_user_file /etc/nginx/.htpasswd; # CORS для фидов add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Allow-Methods "GET, OPTIONS"; } # Админка location /admin/ { proxy_pass http://morele_admin/; 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; # Ограничение доступа по IP # allow 192.168.1.0/24; # deny all; } # Здоровье сервиса location /health { access_log off; return 200 "healthy\n"; add_header Content-Type text/plain; } # Основная страница (перенаправление на админку) location / { return 302 /admin/; } } }