Skip to content

Commit d152881

Browse files
committed
ui: fix nginx conf
Signed-off-by: Viktor Login <[email protected]>
1 parent 2f290ee commit d152881

File tree

1 file changed

+37
-41
lines changed

1 file changed

+37
-41
lines changed

boundaries/ui/ops/conf/nginx.conf

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,75 @@
1-
# One worker process per CPU core
1+
# Load the OpenTelemetry (OTel) module for NGINX
22
load_module modules/ngx_otel_module.so;
3-
worker_processes auto;
4-
pid /tmp/nginx.pid;
5-
env OTEL_EXPORTER_OTLP_ENDPOINT;
3+
4+
worker_processes auto; # Use one worker per CPU core
5+
pid /tmp/nginx.pid; # PID file in /tmp (container-friendly)
6+
env OTEL_EXPORTER_OTLP_ENDPOINT; # Inherit the environment variable into NGINX
67

78
events {
8-
worker_connections 2048;
9-
use epoll;
10-
multi_accept on;
9+
worker_connections 2048; # Max connections per worker
10+
use epoll; # Efficient Linux event notification mechanism
11+
multi_accept on; # Accept multiple connections at once
1112
}
1213

1314
http {
14-
map $env_OTEL_EXPORTER_OTLP_ENDPOINT $otel_exporter_endpoint {
15-
default $env_OTEL_EXPORTER_OTLP_ENDPOINT;
15+
# Map the environment variable to a configuration variable, with fallback
16+
map $OTEL_EXPORTER_OTLP_ENDPOINT $otel_exporter_endpoint {
17+
default $OTEL_EXPORTER_OTLP_ENDPOINT;
1618
"" "http://grafana-tempo.grafana:4317";
1719
}
1820

21+
# OpenTelemetry exporter configuration
1922
otel_exporter {
20-
endpoint $otel_exporter_endpoint;
21-
interval 1s;
22-
batch_size 2048;
23-
}
24-
25-
map $request_time $adaptive_sample {
26-
~^0\.[0-4] 0.001;
27-
~^0\.[5-9] 0.01;
28-
~^[1-2]\. 0.1;
29-
default 1.0;
23+
endpoint $otel_exporter_endpoint; # Send spans to this endpoint
24+
interval 1s; # Flush interval
25+
batch_size 2048; # Maximum spans per batch
3026
}
3127

32-
otel_service_name "shortlink-ui";
33-
otel_trace on;
34-
otel_trace_context propagate;
28+
otel_service_name "shortlink-ui"; # Service name seen in tracing backend
29+
otel_trace on; # Enable tracing for HTTP requests
30+
otel_trace_context propagate; # Propagate W3C trace context to upstream
3531

36-
# Temp paths (safe for container environments)
32+
# Temporary file paths (suitable for containers)
3733
proxy_temp_path /tmp/proxy_temp;
3834
client_body_temp_path /tmp/client_temp;
3935
fastcgi_temp_path /tmp/fastcgi_temp;
4036
uwsgi_temp_path /tmp/uwsgi_temp;
4137
scgi_temp_path /tmp/scgi_temp;
4238

43-
# Static file optimizations
39+
# Static file & connection optimisations
4440
sendfile on;
4541
tcp_nopush on;
4642
tcp_nodelay on;
4743
keepalive_timeout 65s;
4844
keepalive_requests 1000;
4945

50-
# MIME types
5146
include /etc/nginx/mime.types;
5247
default_type application/octet-stream;
5348

54-
# Logging
49+
# Logging in JSON format, including trace IDs
5550
map $upstream_response_time $temprt {
5651
default $upstream_response_time;
5752
"" 0;
5853
}
5954

6055
log_format json escape=json
61-
'{ "@timestamp": "$time_iso8601", '
62-
'"remote_addr": "$remote_addr", '
63-
'"body_bytes_sent": "$body_bytes_sent", '
64-
'"status": $status, '
65-
'"request": "$request", '
66-
'"url": "$uri", '
67-
'"request_method": "$request_method", '
68-
'"response_time": $temprt, '
69-
'"trace_id": "$otel_trace_id", '
70-
'"span_id": "$otel_span_id", '
71-
'"http_referrer": "$http_referer", '
72-
'"http_user_agent": "$http_user_agent" }';
56+
'{ "@timestamp":"$time_iso8601",'
57+
'"remote_addr":"$remote_addr",'
58+
'"body_bytes_sent":"$body_bytes_sent",'
59+
'"status":$status,'
60+
'"request":"$request",'
61+
'"url":"$uri",'
62+
'"request_method":"$request_method",'
63+
'"response_time":"$temprt",'
64+
'"trace_id":"$otel_trace_id",'
65+
'"span_id":"$otel_span_id",'
66+
'"http_referrer":"$http_referer",'
67+
'"http_user_agent":"$http_user_agent"}';
7368

74-
access_log /var/log/nginx/access.log json;
75-
error_log /var/log/nginx/error.log warn;
69+
access_log /var/log/nginx/access.log json;
70+
error_log /var/log/nginx/error.log warn;
7671

77-
# Gzip compression (no double-compress on already-compressed formats)
72+
# Gzip compression settings
7873
gzip on;
7974
gzip_min_length 10240;
8075
gzip_proxied any;
@@ -88,5 +83,6 @@ http {
8883
application/javascript
8984
image/svg+xml;
9085

86+
# Include other server/location configs
9187
include /etc/nginx/conf.d/*;
9288
}

0 commit comments

Comments
 (0)