Cybersecurity-Projects/PROJECTS/advanced/encrypted-p2p-chat/conf/nginx/dev.nginx

82 lines
2.3 KiB
Nginx Configuration File

# ©AngelaMos | 2025
# Development Nginx Configuration
# - Proxies to Vite dev server (HMR/WebSocket support)
# - Proxies /api and /ws to FastAPI backend
# - No caching, verbose logging
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
include /etc/nginx/http.conf;
default_type application/octet-stream;
access_log /var/log/nginx/access.log main_timed;
sendfile off;
tcp_nodelay on;
keepalive_timeout 65;
server {
listen 80;
listen [::]:80;
server_name _;
client_max_body_size 10M;
# WebSocket to backend
location /ws {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
# API routes
location /api {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
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_buffering off;
proxy_request_buffering off;
}
# Vite dev server with HMR
location / {
proxy_pass http://frontend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_read_timeout 60s;
proxy_buffering off;
}
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
}