Saad-gengini commited on
Commit
fdce58a
·
1 Parent(s): b60ea41

Track sqlite databases with git-lfs

Browse files
Files changed (1) hide show
  1. nginx.conf +17 -33
nginx.conf CHANGED
@@ -1,41 +1,25 @@
1
- # /etc/nginx/nginx.conf
2
- events {}
3
 
4
- http {
5
- # Upstream for FastAPI
6
- upstream fastapi_backend {
7
- server 127.0.0.1:8000;
8
- }
9
 
10
- # (Optional) upstream for something on 9200, e.g. Elasticsearch
11
- upstream es_backend {
12
- server 127.0.0.1:9200;
13
- }
14
 
 
 
 
 
15
  server {
16
- # Must match your app_port (7860)
17
- listen 7860;
18
-
19
- # FastAPI exposed as /api/...
20
- location /api/ {
21
- proxy_pass http://fastapi_backend/;
22
- proxy_set_header Host $host;
23
- proxy_set_header X-Real-IP $remote_addr;
24
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
25
- }
26
-
27
- # Optional: proxy /es/ to port 9200
28
- location /es/ {
29
- proxy_pass http://es_backend/;
30
- proxy_set_header Host $host;
31
- proxy_set_header X-Real-IP $remote_addr;
32
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33
- }
34
-
35
- # Optional: serve a static frontend or simple index
36
  location / {
37
- return 200 "Nginx is up. Try /api/hello\n";
38
- add_header Content-Type text/plain;
 
39
  }
40
  }
41
  }
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -e
3
 
4
+ echo "Starting FastAPI + Nginx on port ${PORT}"
 
 
 
 
5
 
6
+ # Start FastAPI in background
7
+ uvicorn app:app --host 0.0.0.0 --port 8000 &
 
 
8
 
9
+ # Configure Nginx dynamically to proxy from $PORT → FastAPI 8000
10
+ cat >/etc/nginx/nginx.conf <<EOF
11
+ events {}
12
+ http {
13
  server {
14
+ listen ${PORT};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  location / {
16
+ proxy_pass http://127.0.0.1:8000;
17
+ proxy_set_header Host \$host;
18
+ proxy_set_header X-Real-IP \$remote_addr;
19
  }
20
  }
21
  }
22
+ EOF
23
+
24
+ # Start Nginx in the foreground (keeps container alive)
25
+ nginx -g "daemon off;"