major fixes

This commit is contained in:
Your Name
2026-05-14 16:58:06 +00:00
parent ad84c38641
commit 36e71ead7b
4 changed files with 20 additions and 123 deletions
+10 -72
View File
@@ -1,6 +1,7 @@
# ==========================================
# CoopCredits Nginx Configuration
# Production - coop.hobokenchicken.com
# Production coop.hobokenchicken.com
# SSL handled by Caddy; this serves plain HTTP
# ==========================================
user nginx;
@@ -18,7 +19,6 @@ http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging format
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
@@ -27,7 +27,6 @@ http {
access_log /var/log/nginx/access.log main;
# Performance
sendfile on;
tcp_nopush on;
tcp_nodelay on;
@@ -35,69 +34,29 @@ http {
types_hash_max_size 2048;
client_max_body_size 50M;
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript
gzip_types text/plain text/css text/xml application/json application/javascript
application/rss+xml application/atom+xml image/svg+xml;
# Rate limiting zones
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
limit_req_zone $binary_remote_addr zone=webhooks:10m rate=100r/s;
limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m;
limit_conn_zone $binary_remote_addr zone=addr:10m;
# Upstream servers
upstream frontend {
server frontend:3000 max_fails=3 fail_timeout=30s;
}
upstream backend {
server backend:3001 max_fails=3 fail_timeout=30s;
server backend:3002 max_fails=3 fail_timeout=30s;
}
# ==========================================
# HTTP Server - Redirect to HTTPS
# ==========================================
server {
listen 80;
server_name coop.hobokenchicken.com;
# Let's Encrypt challenge
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
# Redirect all HTTP to HTTPS
location / {
return 301 https://$server_name$request_uri;
}
}
# ==========================================
# HTTPS Server - Main Application
# ==========================================
server {
listen 443 ssl http2;
server_name coop.hobokenchicken.com;
# SSL Certificates
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
# Alternative: Let's Encrypt certificates
# ssl_certificate /etc/letsencrypt/live/coop.hobokenchicken.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/coop.hobokenchicken.com/privkey.pem;
# SSL Configuration
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;
ssl_session_tickets off;
# Security Headers
add_header X-Frame-Options "SAMEORIGIN" always;
@@ -107,9 +66,6 @@ http {
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self' https://api.devnet.solana.com wss:;" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
# ==========================================
# Frontend - Next.js App
# ==========================================
location / {
proxy_pass http://frontend;
proxy_http_version 1.1;
@@ -118,51 +74,42 @@ http {
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-Proto https;
proxy_cache_bypass $http_upgrade;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# ==========================================
# API Endpoints
# ==========================================
location /api/ {
limit_req zone=api burst=20 nodelay;
limit_conn addr 10;
proxy_pass http://backend/api/;
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_set_header X-Forwarded-Proto https;
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
# ==========================================
# Webhooks (higher rate limit)
# ==========================================
location /webhooks/ {
limit_req zone=webhooks burst=50 nodelay;
proxy_pass http://backend/webhooks/;
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_set_header X-Forwarded-Proto https;
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
# ==========================================
# WebSocket Support (Socket.io)
# ==========================================
location /socket.io/ {
proxy_pass http://backend/socket.io/;
proxy_http_version 1.1;
@@ -171,32 +118,23 @@ http {
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-Proto https;
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
}
# ==========================================
# Static Assets (cache optimization)
# ==========================================
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
proxy_pass http://frontend;
expires 1y;
add_header Cache-Control "public, immutable";
}
# ==========================================
# Health Check Endpoint
# ==========================================
location /health {
proxy_pass http://backend/health;
access_log off;
}
# ==========================================
# Error Pages
# ==========================================
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;