mirror of
https://github.com/Cccc-owo/CheckInApp.git
synced 2026-06-17 14:06:28 +00:00
refactor: v2
backend & frontend
This commit is contained in:
@@ -0,0 +1,216 @@
|
||||
# ==============================================================================
|
||||
# CheckIn App V2 - Nginx Configuration Example
|
||||
# ==============================================================================
|
||||
#
|
||||
# Usage:
|
||||
# 1. Copy this file: sudo cp nginx.conf.example /etc/nginx/sites-available/checkin-app
|
||||
# 2. Edit the file and replace placeholders with your actual values
|
||||
# 3. Create symlink: sudo ln -s /etc/nginx/sites-available/checkin-app /etc/nginx/sites-enabled/
|
||||
# 4. Test config: sudo nginx -t
|
||||
# 5. Reload Nginx: sudo systemctl reload nginx
|
||||
#
|
||||
# ==============================================================================
|
||||
|
||||
# Upstream backend API server
|
||||
upstream checkin_backend {
|
||||
# Backend FastAPI server running on port 8000
|
||||
server 127.0.0.1:8000;
|
||||
|
||||
# Optional: Add more backend servers for load balancing
|
||||
# server 127.0.0.1:8001;
|
||||
# server 127.0.0.1:8002;
|
||||
|
||||
# Keep alive connections
|
||||
keepalive 32;
|
||||
}
|
||||
|
||||
# HTTP Server - Redirect to HTTPS (optional)
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name your-domain.com www.your-domain.com;
|
||||
|
||||
# Redirect all HTTP traffic to HTTPS
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
# HTTPS Server
|
||||
server {
|
||||
# SSL Configuration
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name your-domain.com www.your-domain.com;
|
||||
|
||||
# SSL Certificate (Let's Encrypt recommended)
|
||||
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
|
||||
|
||||
# SSL Configuration (Modern)
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
|
||||
ssl_prefer_server_ciphers off;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
# Security Headers
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Root directory for frontend static files
|
||||
root /opt/checkin-app/frontend/dist;
|
||||
index index.html;
|
||||
|
||||
# Access and Error Logs
|
||||
access_log /var/log/nginx/checkin-app-access.log;
|
||||
error_log /var/log/nginx/checkin-app-error.log;
|
||||
|
||||
# Gzip Compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
||||
|
||||
# Client body size (for file uploads)
|
||||
client_max_body_size 10M;
|
||||
|
||||
# ==========================================
|
||||
# API Proxy Configuration
|
||||
# ==========================================
|
||||
location /api/ {
|
||||
# Proxy to backend
|
||||
proxy_pass http://checkin_backend;
|
||||
|
||||
# Proxy headers
|
||||
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;
|
||||
|
||||
# WebSocket support (if needed)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Timeouts
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
|
||||
# Buffering
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
|
||||
# API Documentation
|
||||
location /docs {
|
||||
proxy_pass http://checkin_backend;
|
||||
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 /redoc {
|
||||
proxy_pass http://checkin_backend;
|
||||
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 /openapi.json {
|
||||
proxy_pass http://checkin_backend;
|
||||
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;
|
||||
}
|
||||
|
||||
# ==========================================
|
||||
# Frontend Static Files
|
||||
# ==========================================
|
||||
|
||||
# Cache static assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Frontend routes (SPA)
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# Favicon
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# Robots.txt
|
||||
location = /robots.txt {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# Health check endpoint
|
||||
location /health {
|
||||
proxy_pass http://checkin_backend;
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# Alternative: HTTP-only configuration (for development/internal use)
|
||||
# ==============================================================================
|
||||
# Uncomment below if you don't need HTTPS
|
||||
|
||||
# server {
|
||||
# listen 80;
|
||||
# listen [::]:80;
|
||||
# server_name your-domain.com;
|
||||
#
|
||||
# root /opt/checkin-app/frontend/dist;
|
||||
# index index.html;
|
||||
#
|
||||
# access_log /var/log/nginx/checkin-app-access.log;
|
||||
# error_log /var/log/nginx/checkin-app-error.log;
|
||||
#
|
||||
# gzip on;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
#
|
||||
# client_max_body_size 10M;
|
||||
#
|
||||
# # API Proxy
|
||||
# location /api/ {
|
||||
# proxy_pass http://127.0.0.1:8000;
|
||||
# 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_http_version 1.1;
|
||||
# proxy_buffering off;
|
||||
# }
|
||||
#
|
||||
# # API Documentation
|
||||
# location ~ ^/(docs|redoc|openapi.json) {
|
||||
# proxy_pass http://127.0.0.1:8000;
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# }
|
||||
#
|
||||
# # Static files
|
||||
# location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||||
# expires 1y;
|
||||
# add_header Cache-Control "public";
|
||||
# }
|
||||
#
|
||||
# # Frontend routes
|
||||
# location / {
|
||||
# try_files $uri $uri/ /index.html;
|
||||
# }
|
||||
# }
|
||||
Reference in New Issue
Block a user