Skip to content

Commit a3af4c1

Browse files
committed
error logging
1 parent de7907b commit a3af4c1

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

tools/reverse-proxy/default.conf.template

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ server {
44
listen 80;
55
server_name localhost 127.0.0.1 ${DOMAIN} www.${DOMAIN};
66

7-
location /ops/healthcheck {
7+
# Exact match for /ops/healthcheck (highest priority)
8+
location = /ops/healthcheck {
89
access_log off;
910
return 200 "healthy\n";
1011
add_header Content-Type text/plain;
@@ -13,7 +14,7 @@ server {
1314
location / {
1415
add_header Content-Type text/html;
1516
# Use protocol-relative URLs (//) so they work with both http and https
16-
return 200 "<!DOCTYPE html><html><head><title>UID2 Sample Pages</title><style>body{font-family:Arial,sans-serif;max-width:800px;margin:50px auto;padding:20px;background:#f5f5f5}h1{color:#333}a{display:block;padding:10px;margin:5px 0;background:white;border-left:4px solid #007bff;text-decoration:none;color:#007bff;border-radius:4px}a:hover{background:#e7f3ff;border-left-color:#0056b3}.info{margin-top:30px;padding:15px;background:#fff3cd;border-left:4px solid #ffc107;border-radius:4px}</style></head><body><h1>UID2 Sample Pages</h1><p>Access services using the following subdomains:</p><a href=\"//js-client-side.${DOMAIN}\">js-client-side.${DOMAIN}</a><a href=\"//js-client-server.${DOMAIN}\">js-client-server.${DOMAIN}</a><a href=\"//js-react.${DOMAIN}\">js-react.${DOMAIN}</a><a href=\"//server-side.${DOMAIN}\">server-side.${DOMAIN}</a><a href=\"//secure-signals-client-server.${DOMAIN}\">secure-signals-client-server.${DOMAIN}</a><a href=\"//secure-signals-client-side.${DOMAIN}\">secure-signals-client-side.${DOMAIN}</a><a href=\"//secure-signals-server-side.${DOMAIN}\">secure-signals-server-side.${DOMAIN}</a><a href=\"//secure-signals-react.${DOMAIN}\">secure-signals-react.${DOMAIN}</a><a href=\"//prebid-client.${DOMAIN}\">prebid-client.${DOMAIN}</a><a href=\"//prebid-client-server.${DOMAIN}\">prebid-client-server.${DOMAIN}</a><a href=\"//prebid-secure-signals.${DOMAIN}\">prebid-secure-signals.${DOMAIN}</a><div class=\"info\"><strong>Note:</strong> Add these subdomains to your hosts file (127.0.0.1) to use them.</div></body></html>";
17+
return 200 "<!DOCTYPE html><html><head><title>UID2 Sample Pages</title><style>body{font-family:Arial,sans-serif;max-width:800px;margin:50px auto;padding:20px;background:#f5f5f5}h1{color:#333}a{display:block;padding:10px;margin:5px 0;background:white;border-left:4px solid #007bff;text-decoration:none;color:#007bff;border-radius:4px}a:hover{background:#e7f3ff;border-left-color:#0056b3}.info{margin-top:30px;padding:15px;background:#fff3cd;border-left:4px solid #ffc107;border-radius:4px}</style></head><body><h1>UID2 Sample Pages</h1><p>Access services using the following subdomains:</p><a href=\"//js-client-side.${DOMAIN}\">js-client-side.${DOMAIN}</a><a href=\"//js-client-server.${DOMAIN}\">js-client-server.${DOMAIN}</a><a href=\"//js-react.${DOMAIN}\">js-react.${DOMAIN}</a><a href=\"//server-side.${DOMAIN}\">server-side.${DOMAIN}</a><a href=\"//secure-signals-client-server.${DOMAIN}\">secure-signals-client-server.${DOMAIN}</a><a href=\"//secure-signals-client-side.${DOMAIN}\">secure-signals-client-side.${DOMAIN}</a><a href=\"//secure-signals-server-side.${DOMAIN}\">secure-signals-server-side.${DOMAIN}</a><a href=\"//secure-signals-react.${DOMAIN}\">secure-signals-react.${DOMAIN}</a><a href=\"//prebid-client.${DOMAIN}\">prebid-client.${DOMAIN}</a><a href=\"//prebid-client-server.${DOMAIN}\">prebid-client-server.${DOMAIN}</a><a href=\"//prebid-secure-signals.${DOMAIN}\">prebid-secure-signals.${DOMAIN}</a><div class=\"info\"><strong>Note:</strong> For local development, add ${DOMAIN} and all subdomains to your hosts file (127.0.0.1) to use them. Example: <code>127.0.0.1 ${DOMAIN} js-client-side.${DOMAIN} ...</code></div></body></html>";
1718
}
1819
}
1920

@@ -22,7 +23,8 @@ server {
2223
listen 80 default_server;
2324
server_name _;
2425

25-
location /ops/healthcheck {
26+
# Exact match for /ops/healthcheck (highest priority)
27+
location = /ops/healthcheck {
2628
access_log off;
2729
return 200 "healthy\n";
2830
add_header Content-Type text/plain;
@@ -40,7 +42,8 @@ server {
4042
server_name js-client-side.${DOMAIN} *.js-client-side.${DOMAIN};
4143
resolver 127.0.0.11 valid=10s;
4244

43-
location /ops/healthcheck {
45+
# Exact match for /ops/healthcheck (highest priority)
46+
location = /ops/healthcheck {
4447
access_log off;
4548
return 200 "healthy\n";
4649
add_header Content-Type text/plain;
@@ -66,7 +69,8 @@ server {
6669
server_name js-client-server.${DOMAIN} *.js-client-server.${DOMAIN};
6770
resolver 127.0.0.11 valid=10s;
6871

69-
location /ops/healthcheck {
72+
# Exact match for /ops/healthcheck (highest priority)
73+
location = /ops/healthcheck {
7074
access_log off;
7175
return 200 "healthy\n";
7276
add_header Content-Type text/plain;
@@ -92,7 +96,8 @@ server {
9296
server_name js-react.${DOMAIN} *.js-react.${DOMAIN};
9397
resolver 127.0.0.11 valid=10s;
9498

95-
location /ops/healthcheck {
99+
# Exact match for /ops/healthcheck (highest priority)
100+
location = /ops/healthcheck {
96101
access_log off;
97102
return 200 "healthy\n";
98103
add_header Content-Type text/plain;
@@ -118,7 +123,8 @@ server {
118123
server_name server-side.${DOMAIN} *.server-side.${DOMAIN};
119124
resolver 127.0.0.11 valid=10s;
120125

121-
location /ops/healthcheck {
126+
# Exact match for /ops/healthcheck (highest priority)
127+
location = /ops/healthcheck {
122128
access_log off;
123129
return 200 "healthy\n";
124130
add_header Content-Type text/plain;
@@ -144,7 +150,8 @@ server {
144150
server_name secure-signals-client-server.${DOMAIN} *.secure-signals-client-server.${DOMAIN};
145151
resolver 127.0.0.11 valid=10s;
146152

147-
location /ops/healthcheck {
153+
# Exact match for /ops/healthcheck (highest priority)
154+
location = /ops/healthcheck {
148155
access_log off;
149156
return 200 "healthy\n";
150157
add_header Content-Type text/plain;
@@ -170,7 +177,8 @@ server {
170177
server_name secure-signals-client-side.${DOMAIN} *.secure-signals-client-side.${DOMAIN};
171178
resolver 127.0.0.11 valid=10s;
172179

173-
location /ops/healthcheck {
180+
# Exact match for /ops/healthcheck (highest priority)
181+
location = /ops/healthcheck {
174182
access_log off;
175183
return 200 "healthy\n";
176184
add_header Content-Type text/plain;
@@ -196,7 +204,8 @@ server {
196204
server_name secure-signals-server-side.${DOMAIN} *.secure-signals-server-side.${DOMAIN};
197205
resolver 127.0.0.11 valid=10s;
198206

199-
location /ops/healthcheck {
207+
# Exact match for /ops/healthcheck (highest priority)
208+
location = /ops/healthcheck {
200209
access_log off;
201210
return 200 "healthy\n";
202211
add_header Content-Type text/plain;
@@ -222,7 +231,8 @@ server {
222231
server_name secure-signals-react.${DOMAIN} *.secure-signals-react.${DOMAIN};
223232
resolver 127.0.0.11 valid=10s;
224233

225-
location /ops/healthcheck {
234+
# Exact match for /ops/healthcheck (highest priority)
235+
location = /ops/healthcheck {
226236
access_log off;
227237
return 200 "healthy\n";
228238
add_header Content-Type text/plain;
@@ -248,7 +258,8 @@ server {
248258
server_name prebid-client.${DOMAIN} *.prebid-client.${DOMAIN};
249259
resolver 127.0.0.11 valid=10s;
250260

251-
location /ops/healthcheck {
261+
# Exact match for /ops/healthcheck (highest priority)
262+
location = /ops/healthcheck {
252263
access_log off;
253264
return 200 "healthy\n";
254265
add_header Content-Type text/plain;
@@ -258,13 +269,23 @@ server {
258269
set $backend "prebid-client";
259270
proxy_pass http://$backend:3051;
260271
proxy_redirect off;
261-
proxy_connect_timeout 5s;
272+
proxy_connect_timeout 10s;
262273
proxy_send_timeout 60s;
263274
proxy_read_timeout 60s;
275+
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
264276
proxy_set_header Host $host;
265277
proxy_set_header X-Real-IP $remote_addr;
266278
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
267279
proxy_set_header X-Forwarded-Proto $scheme;
280+
281+
# Add error handling
282+
proxy_intercept_errors on;
283+
error_page 502 503 504 = @backend_error;
284+
}
285+
286+
location @backend_error {
287+
return 503 "Service Unavailable: Backend service 'prebid-client' is not reachable. Please check if the service is running and on the same Docker network.";
288+
add_header Content-Type text/plain;
268289
}
269290
}
270291

@@ -274,7 +295,8 @@ server {
274295
server_name prebid-client-server.${DOMAIN} *.prebid-client-server.${DOMAIN};
275296
resolver 127.0.0.11 valid=10s;
276297

277-
location /ops/healthcheck {
298+
# Exact match for /ops/healthcheck (highest priority)
299+
location = /ops/healthcheck {
278300
access_log off;
279301
return 200 "healthy\n";
280302
add_header Content-Type text/plain;
@@ -300,7 +322,8 @@ server {
300322
server_name prebid-secure-signals.${DOMAIN} *.prebid-secure-signals.${DOMAIN};
301323
resolver 127.0.0.11 valid=10s;
302324

303-
location /ops/healthcheck {
325+
# Exact match for /ops/healthcheck (highest priority)
326+
location = /ops/healthcheck {
304327
access_log off;
305328
return 200 "healthy\n";
306329
add_header Content-Type text/plain;

0 commit comments

Comments
 (0)