File tree 5 files changed +63
-10
lines changed
5 files changed +63
-10
lines changed Original file line number Diff line number Diff line change 29
29
cd ~/gitdiagram
30
30
git fetch origin main
31
31
git reset --hard origin/main # Force local to match remote main
32
- chmod +x ./backend/deploy.sh # Make the script executable
32
+ sudo chmod +x ./backend/nginx/setup_nginx.sh
33
+ sudo ./backend/nginx/setup_nginx.sh
34
+ chmod +x ./backend/deploy.sh
33
35
./backend/deploy.sh
Original file line number Diff line number Diff line change 9
9
from api_analytics .fastapi import Analytics
10
10
import os
11
11
12
- from time import sleep
13
-
14
12
15
13
app = FastAPI ()
16
14
app .state .limiter = limiter
43
41
@limiter .limit ("100/day" )
44
42
async def root (request : Request ):
45
43
return {"message" : "Hello from GitDiagram API!" }
46
-
47
-
48
- @app .get ("/slow" )
49
- async def slow (request : Request ):
50
- sleep (120 )
51
- return {"message" : "slow" }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ if [ "$ENVIRONMENT" = "development" ]; then
7
7
exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
8
8
elif [ " $ENVIRONMENT " = " production" ]; then
9
9
echo " Starting in production mode with multiple workers..."
10
- exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 2
10
+ exec uvicorn app.main:app --host 0.0.0.0 --port 8000 --timeout-keep-alive 300 -- workers 2
11
11
else
12
12
echo " ENVIRONMENT must be set to either 'development' or 'production'"
13
13
exit 1
Original file line number Diff line number Diff line change
1
+ server {
2
+ server_name api.gitdiagram.com;
3
+
4
+ location / {
5
+ proxy_pass http://127.0.0.1:8000; # Forward to FastAPI
6
+ include proxy_params;
7
+ proxy_redirect off;
8
+ }
9
+
10
+ # Add timeout settings
11
+ proxy_connect_timeout 300;
12
+ proxy_send_timeout 300;
13
+ proxy_read_timeout 300;
14
+ send_timeout 300;
15
+
16
+ # todo: stop weird requests from being made
17
+
18
+ listen 443 ssl; # managed by Certbot
19
+ ssl_certificate /etc/letsencrypt/live/api.gitdiagram.com/fullchain.pem; # managed by Certbot
20
+ ssl_certificate_key /etc/letsencrypt/live/api.gitdiagram.com/privkey.pem; # managed by Certbot
21
+ include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
22
+ ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
23
+
24
+ }
25
+ server {
26
+ if ($host = api.gitdiagram.com) {
27
+ return 301 https://$host$request_uri;
28
+ } # managed by Certbot
29
+
30
+
31
+ listen 80;
32
+ server_name api.gitdiagram.com;
33
+ return 404; # managed by Certbot
34
+ }
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # Exit on any error
4
+ set -e
5
+
6
+ # Check if running as root
7
+ if [ " $EUID " -ne 0 ]; then
8
+ echo " Please run as root or with sudo"
9
+ exit 1
10
+ fi
11
+
12
+ # Copy Nginx configuration
13
+ echo " Copying Nginx configuration..."
14
+ cp ./api.conf /etc/nginx/sites-available/api
15
+ ln -sf /etc/nginx/sites-available/api /etc/nginx/sites-enabled/
16
+
17
+ # Test Nginx configuration
18
+ echo " Testing Nginx configuration..."
19
+ nginx -t
20
+
21
+ # Reload Nginx
22
+ echo " Reloading Nginx..."
23
+ systemctl reload nginx
24
+
25
+ echo " Nginx configuration updated successfully!"
You can’t perform that action at this time.
0 commit comments