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

48 lines
1.4 KiB
Nginx Configuration File
Raw Normal View History

2024-10-25 22:57:10 -04:00
worker_processes 1;
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;
2024-10-25 22:57:10 -04:00
upstream django {
server 127.0.0.1:8000;
2024-10-25 22:57:10 -04:00
}
2024-10-25 22:57:10 -04:00
server {
listen 80;
2024-10-25 22:57:10 -04:00
server_name localhost;
2024-10-25 22:57:10 -04:00
location / {
proxy_pass http://django;
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;
}
2024-10-25 22:57:10 -04:00
location /static/ {
alias /code/staticfiles/;
2024-10-25 22:57:10 -04:00
}
# Special handling for PDF files with CSP headers
location ~ ^/protectedMedia/(.*)\.pdf$ {
internal;
alias /code/media/$1.pdf;
add_header Content-Security-Policy "default-src 'self'; script-src 'none'; object-src 'none'; base-uri 'none'" always;
add_header X-Content-Type-Options nosniff always;
add_header X-Frame-Options SAMEORIGIN always;
add_header Content-Disposition "inline" always;
}
# General protected media files (non-PDF)
location ~ ^/protectedMedia/(.*)$ {
internal;
alias /code/media/$1;
}
2024-10-25 22:57:10 -04:00
}
}