Files
k8s-oauth-demo-spa/nginx.conf
2025-09-16 15:43:36 +05:00

49 lines
1.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.

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Сжатие для лучшей производительности
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Кэширование статических ресурсов
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Для SPA - все маршруты направляем на index.html
location / {
try_files $uri $uri/ /index.html;
# Заголовки безопасности
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
}
# API endpoint для получения информации о пользователе
location /api/user {
# В реальном приложении здесь будет проксирование к backend
# Для демо возвращаем информацию из заголовков OAuth2 proxy
add_header Content-Type application/json;
return 200 '{"name": "Демо Пользователь", "email": "demo@example.com"}';
}
# Health check endpoint
location /health {
add_header Content-Type application/json;
return 200 '{"status": "ok"}';
}
}