|
| 1 | +upstream optifood_backend { |
| 2 | + server 127.0.0.1:8000; |
| 3 | +} |
| 4 | + |
| 5 | +upstream seratonin_backend { |
| 6 | + server 127.0.0.1:8001; |
| 7 | +} |
| 8 | + |
| 9 | +server { |
| 10 | + server_name optifood-ai.duckdns.org; |
| 11 | + |
| 12 | + client_max_body_size 20M; |
| 13 | + |
| 14 | + # Block scanners and hidden files |
| 15 | + location ~ /\.(?!well-known).* { |
| 16 | + deny all; |
| 17 | + access_log off; |
| 18 | + log_not_found off; |
| 19 | + } |
| 20 | + |
| 21 | + location ~* /(vendor|phpunit|laravel|wp-admin|wp-content|backup|myadmin|setup|config) { |
| 22 | + access_log off; |
| 23 | + log_not_found off; |
| 24 | + return 444; |
| 25 | + } |
| 26 | + |
| 27 | + location ~* \.php$ { |
| 28 | + access_log off; |
| 29 | + log_not_found off; |
| 30 | + return 444; |
| 31 | + } |
| 32 | + |
| 33 | + # Optifood (root) |
| 34 | + location / { |
| 35 | + proxy_pass http://optifood_backend; |
| 36 | + proxy_set_header Host $host; |
| 37 | + proxy_set_header X-Real-IP $remote_addr; |
| 38 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 39 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 40 | + proxy_connect_timeout 60s; |
| 41 | + proxy_read_timeout 120s; |
| 42 | + proxy_send_timeout 120s; |
| 43 | + } |
| 44 | + |
| 45 | + # Seratonin — strip /seratonin prefix before passing to FastAPI |
| 46 | + location /seratonin/ { |
| 47 | + proxy_pass http://seratonin_backend/; |
| 48 | + proxy_set_header Host $host; |
| 49 | + proxy_set_header X-Real-IP $remote_addr; |
| 50 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 51 | + proxy_set_header X-Forwarded-Proto $scheme; |
| 52 | + proxy_connect_timeout 60s; |
| 53 | + proxy_read_timeout 120s; |
| 54 | + proxy_send_timeout 120s; |
| 55 | + } |
| 56 | + |
| 57 | + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; |
| 58 | + add_header X-Frame-Options SAMEORIGIN; |
| 59 | + add_header X-Content-Type-Options nosniff; |
| 60 | + add_header X-XSS-Protection "1; mode=block"; |
| 61 | + |
| 62 | + listen 443 ssl; |
| 63 | + ssl_certificate /etc/letsencrypt/live/optifood-ai.duckdns.org/fullchain.pem; |
| 64 | + ssl_certificate_key /etc/letsencrypt/live/optifood-ai.duckdns.org/privkey.pem; |
| 65 | + include /etc/letsencrypt/options-ssl-nginx.conf; |
| 66 | + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; |
| 67 | +} |
| 68 | + |
| 69 | +server { |
| 70 | + listen 80; |
| 71 | + server_name optifood-ai.duckdns.org; |
| 72 | + |
| 73 | + if ($host = optifood-ai.duckdns.org) { |
| 74 | + return 301 https://$host$request_uri; |
| 75 | + } |
| 76 | + |
| 77 | + return 404; |
| 78 | +} |
0 commit comments