Skip to content

Commit 7e25ca4

Browse files
simplify nginx conf
1 parent 9f69eb6 commit 7e25ca4

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

backend/nginx/api.conf

+3-35
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ server {
66
return 444;
77
}
88

9-
# Only allow specific paths with specific methods
10-
location ~ ^/(generate(/cost)?|modify)$ {
11-
12-
# Only allow specific methods
9+
# Strictly allow only GET, POST, and OPTIONS requests for the specified paths (defined in my fastapi app)
10+
location ~ ^/(generate(/cost)?|modify|)?$ {
1311
if ($request_method !~ ^(GET|POST|OPTIONS)$) {
1412
return 444;
1513
}
@@ -19,40 +17,10 @@ server {
1917
proxy_redirect off;
2018
}
2119

22-
# Allow root path GET requests
23-
location = / {
24-
if ($request_method !~ ^(GET|OPTIONS)$) {
25-
return 444;
26-
}
27-
28-
proxy_pass http://127.0.0.1:8000;
29-
include proxy_params;
30-
proxy_redirect off;
31-
}
32-
3320
# Return 444 for everything else (no response, just close connection)
3421
location / {
3522
return 444;
36-
}
37-
38-
# Block common web crawling targets
39-
location = /favicon.ico {
40-
return 404;
41-
access_log off;
42-
log_not_found off;
43-
}
44-
45-
location = /robots.txt {
46-
return 404;
47-
access_log off;
48-
log_not_found off;
49-
}
50-
51-
# Block access to hidden files
52-
location ~ /\. {
53-
deny all;
54-
access_log off;
55-
log_not_found off;
23+
# keep access log on
5624
}
5725

5826
# Add timeout settings

0 commit comments

Comments
 (0)