-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
103 lines (86 loc) · 3.45 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Used for PaaS deployment
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Enable access logs with more details
log_format detailed '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time';
access_log /var/log/nginx/access.log detailed;
error_log /var/log/nginx/error.log debug;
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Prevent redirect loops
absolute_redirect off;
# Direct file matches - no rewrites or fallbacks
location = /favicon.ico {
try_files $uri =404;
access_log /var/log/nginx/favicon-access.log detailed;
error_log /var/log/nginx/favicon-error.log debug;
expires 30d;
add_header Cache-Control "public, no-transform";
add_header X-Debug-Message "Serving favicon" always;
error_page 404 =404; # Prevent falling back to index.html
}
location = /ads.txt {
alias /usr/share/nginx/html/ads.txt;
access_log off;
expires 1h;
add_header Cache-Control "public, no-transform";
error_page 404 =404 /404.html;
}
location = /robots.txt {
alias /usr/share/nginx/html/robots.txt;
access_log off;
expires 1h;
add_header Cache-Control "public, no-transform";
}
location = /sitemap.xml {
alias /usr/share/nginx/html/sitemap.xml;
access_log off;
expires 1h;
add_header Cache-Control "public, no-transform";
add_header Content-Type "application/xml";
}
# Serve static frontend files and handle client-side routing
location / {
# First attempt to serve request as file or directory
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
# Add headers for debugging
add_header X-Debug-Message "Serving frontend file" always;
}
# Handle /cookies route
location = /cookies {
try_files /index.html =404;
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
add_header X-Debug-Message "Serving cookies page" always;
}
# Proxy API requests
location /api/ {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Add headers for debugging
add_header X-Debug-Message "Proxying to API" always;
}
# Handle 404 errors - but not for favicon.ico and ads.txt
error_page 404 /index.html;
}
}