Skip to content

Commit fa22239

Browse files
committed
Update error handling and enhance NGINX configuration
Improved login error reporting in `auth.py` to include exception details for better debugging. Updated `nginx.conf` to clean up server directives, enforce HTTPS redirect, and enhance security and flexibility with revised headers, buffer size, and timeout settings.
1 parent bc87c10 commit fa22239

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

app/api/v1/endpoints/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def login(
8383
logger.error("Login failed", error=str(e), email=email)
8484
raise HTTPException(
8585
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
86-
detail="Login failed"
86+
detail=f"Login failed {str(e)}"
8787
)
8888

8989

nginx.conf

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1+
12
server {
23
listen 80;
3-
server_name intellibank.duckdns.org 24.144.109.220;
4-
return 301 https://intellibank.duckdns.org$request_uri;
4+
server_name intellibank.duckdns.org;
5+
return 301 https://$host$request_uri;
56
}
67

8+
# Main HTTPS server
79
server {
8-
listen 443 ssl;
9-
server_name intellibank.duckdns.org 24.144.109.220;
10+
listen 443 ssl http2;
11+
server_name intellibank.duckdns.org;
1012

11-
# SSL configuration (replace paths with your certs)
12-
ssl_certificate /etc/letsencrypt/live/intellibank.duckdns.org/fullchain.pem;
13+
# SSL certs created by Certbot / Let’s Encrypt
14+
ssl_certificate /etc/letsencrypt/live/intellibank.duckdns.org/fullchain.pem;
1315
ssl_certificate_key /etc/letsencrypt/live/intellibank.duckdns.org/privkey.pem;
1416
ssl_trusted_certificate /etc/letsencrypt/live/intellibank.duckdns.org/chain.pem;
1517

16-
# Security headers
18+
# Security headers (optional but recommended)
1719
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
1820
add_header X-Content-Type-Options "nosniff";
1921
add_header X-Frame-Options "SAMEORIGIN";
2022

21-
# Proxy to your backend
23+
# Increase buffer sizes if you have large JSON payloads
24+
client_max_body_size 10M;
25+
2226
location / {
23-
proxy_pass http://127.0.0.1:8000;
27+
proxy_pass http://127.0.0.1:8000; # your FastAPI/Uvicorn
2428
proxy_http_version 1.1;
25-
proxy_set_header Upgrade $http_upgrade;
26-
proxy_set_header Connection "upgrade";
27-
proxy_set_header Host $host;
28-
proxy_set_header X-Real-IP $remote_addr;
29-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
30-
proxy_set_header X-Forwarded-Proto $scheme;
29+
proxy_set_header Upgrade $http_upgrade;
30+
proxy_set_header Connection "upgrade";
31+
proxy_set_header Host $host;
32+
proxy_set_header X-Real-IP $remote_addr;
33+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34+
proxy_set_header X-Forwarded-Proto $scheme;
35+
proxy_read_timeout 90;
3136
}
32-
}
37+
}

0 commit comments

Comments
 (0)