diff --git a/nginx.conf b/nginx.conf index 270fb79..fdccc87 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,25 +1,45 @@ -server { - listen 80; - server_name acidarchon.com www.acidarchon.com localhost; +# user & worker settings +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; - # Serve static files - location /static/ { - alias /app/staticfiles/; - expires 30d; - add_header Cache-Control "public, immutable"; +events { + worker_connections 1024; +} + +http { + # basic settings + include /etc/nginx/mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + + # upstream for Uvicorn + upstream app { + server 127.0.0.1:8000; } - # Proxy to Django - location / { - proxy_pass http://web:8000; # 'web' is the service name - 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; + server { + listen 80; + server_name _; - # WebSocket support - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; + # serve static files + location /static/ { + alias /app/static/; + expires 30d; + add_header Cache-Control "public"; + } + + # proxy everything else to Uvicorn + location / { + proxy_pass http://app; + 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; + } } } + +