1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-19 12:59:36 +02:00
AdventureLog/backend/nginx.conf

46 lines
1.2 KiB
Nginx Configuration File
Raw Normal View History

2024-10-25 22:57:10 -04:00
worker_processes 1;
2024-10-25 22:57:10 -04:00
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 100M;
# The backend is running in the same container, so reference localhost
2024-10-25 22:57:10 -04:00
upstream django {
server 127.0.0.1:8000; # Use localhost to point to Gunicorn running internally
2024-10-25 22:57:10 -04:00
}
server {
listen 80;
2024-10-25 22:57:10 -04:00
server_name localhost;
location / {
proxy_pass http://django; # Forward to the upstream block
2024-10-25 22:57:10 -04:00
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 /static/ {
alias /code/staticfiles/; # Serve static files directly
}
# Serve protected media files with X-Accel-Redirect
location /protectedMedia/ {
internal; # Only internal requests are allowed
alias /code/media/; # This should match Django MEDIA_ROOT
try_files $uri =404; # Return a 404 if the file doesn't exist
2024-10-25 22:57:10 -04:00
}
2024-10-25 22:57:10 -04:00
}
}