Files
ospab.host/ospabhost/backend/nginx-oauth.conf
Georgiy Syralev d45baf2260 sitemap и тд
2025-11-01 12:29:46 +03:00

105 lines
3.6 KiB
Plaintext
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.
# Nginx конфигурация для React приложения с OAuth (ospab-host)
# Файл: /etc/nginx/sites-available/ospab-oauth
#
# ⚠️ ВАЖНО: Этот конфиг для React приложения (ospab-host)
# Для PHP сайта-визитки используйте nginx-visit.conf
#
# Установка на сервере:
# 1. sudo cp nginx-oauth.conf /etc/nginx/sites-available/ospab-oauth
# 2. sudo ln -s /etc/nginx/sites-available/ospab-oauth /etc/nginx/sites-enabled/
# 3. sudo nginx -t && sudo systemctl reload nginx
server {
listen 443 ssl http2;
server_name ospab.host;
# SSL сертификаты (замените на свои пути)
ssl_certificate /etc/letsencrypt/live/ospab.host/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ospab.host/privkey.pem;
# SSL настройки
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Логи
access_log /var/log/nginx/ospab-oauth-access.log;
error_log /var/log/nginx/ospab-oauth-error.log;
# Проксирование OAuth роутов на backend (порт 5000)
location /api/auth/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
# WebSocket поддержка (если нужно)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
# Заголовки для корректной работы OAuth
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;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_cache_bypass $http_upgrade;
# Таймауты
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Все остальные API запросы (опционально)
location /api/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
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;
# Таймауты
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Статические файлы чеков
location /uploads/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Frontend сайт (React/Vite) - все остальные запросы
location / {
root /var/www/ospab-host/frontend/dist;
try_files $uri $uri/ /index.html;
# Кэширование статических файлов
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Отключить кэширование для index.html
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
}
}
# Редирект с HTTP на HTTPS
server {
listen 80;
server_name ospab.host;
return 301 https://$server_name$request_uri;
}