Skip to content

Commit b419c4b

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

File tree

6 files changed

+52
-90
lines changed

6 files changed

+52
-90
lines changed

boundaries/ui/ops/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ RUN apk add --no-cache curl \
102102
###############################################################################
103103
# NGINX configuration & static assets
104104
###############################################################################
105-
COPY ./ops/conf/ui.local /etc/nginx/conf.d/default.conf
106-
COPY ./ops/conf/nginx.conf /etc/nginx/nginx.conf
107-
COPY ./ops/conf/templates /etc/nginx/template
105+
COPY ./ops/conf/ui.local /etc/nginx/conf.d/default.conf
106+
COPY ./ops/conf/nginx.conf /etc/nginx/nginx.conf
108107

109108
# Next.js export build from the builder stage
110109
COPY --from=builder /app/out /usr/share/nginx/html

boundaries/ui/ops/conf/nginx.conf

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,46 @@
11
# Load the OpenTelemetry (OTel) module for NGINX
22
load_module modules/ngx_otel_module.so;
33

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
4+
worker_processes auto;
5+
pid /tmp/nginx.pid;
6+
error_log /dev/stderr warn;
77

88
events {
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
9+
worker_connections 2048;
10+
use epoll;
11+
multi_accept on;
1212
}
1313

1414
http {
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;
18-
"" "http://grafana-tempo.grafana:4317";
19-
}
15+
include /etc/nginx/mime.types;
16+
default_type application/octet-stream;
2017

21-
# OpenTelemetry exporter configuration
18+
# OTEL exporter
2219
otel_exporter {
23-
endpoint $otel_exporter_endpoint; # Send spans to this endpoint
24-
interval 1s; # Flush interval
25-
batch_size 2048; # Maximum spans per batch
20+
endpoint http://grafana-tempo.grafana:4317;
21+
interval 1s;
22+
batch_size 2048;
2623
}
2724

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
25+
otel_service_name "shortlink-ui";
26+
otel_trace on;
27+
otel_trace_context propagate;
3128

32-
# Temporary file paths (suitable for containers)
29+
# Temp paths (container-safe)
3330
proxy_temp_path /tmp/proxy_temp;
3431
client_body_temp_path /tmp/client_temp;
3532
fastcgi_temp_path /tmp/fastcgi_temp;
3633
uwsgi_temp_path /tmp/uwsgi_temp;
3734
scgi_temp_path /tmp/scgi_temp;
3835

39-
# Static file & connection optimisations
40-
sendfile on;
41-
tcp_nopush on;
42-
tcp_nodelay on;
36+
# IO options
37+
sendfile on;
38+
tcp_nopush on;
39+
tcp_nodelay on;
4340
keepalive_timeout 65s;
4441
keepalive_requests 1000;
4542

46-
include /etc/nginx/mime.types;
47-
default_type application/octet-stream;
48-
49-
# Logging in JSON format, including trace IDs
43+
# Logging (JSON format)
5044
map $upstream_response_time $temprt {
5145
default $upstream_response_time;
5246
"" 0;
@@ -66,14 +60,13 @@ http {
6660
'"http_referrer":"$http_referer",'
6761
'"http_user_agent":"$http_user_agent"}';
6862

69-
access_log /var/log/nginx/access.log json;
70-
error_log /var/log/nginx/error.log warn;
63+
access_log /dev/stdout json;
7164

72-
# Gzip compression settings
73-
gzip on;
74-
gzip_min_length 10240;
75-
gzip_proxied any;
76-
gzip_disable "msie6";
65+
# Gzip
66+
gzip on;
67+
gzip_min_length 10240;
68+
gzip_proxied any;
69+
gzip_disable "msie6";
7770
gzip_types
7871
text/plain
7972
text/css
@@ -83,6 +76,5 @@ http {
8376
application/javascript
8477
image/svg+xml;
8578

86-
# Include other server/location configs
87-
include /etc/nginx/conf.d/*;
79+
include /etc/nginx/conf.d/default.conf;
8880
}

boundaries/ui/ops/conf/ssl/.keep

Whitespace-only changes.

boundaries/ui/ops/conf/templates/default.conf

Lines changed: 0 additions & 23 deletions
This file was deleted.

boundaries/ui/ops/conf/templates/ssl.conf

Lines changed: 0 additions & 13 deletions
This file was deleted.

boundaries/ui/ops/conf/ui.local

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,56 @@
11
server {
2-
listen 8080;
3-
listen [::]:8080;
2+
listen 8080 default_server;
3+
listen [::]:8080 default_server;
44
server_name _;
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
charset utf-8;
8+
59
absolute_redirect off;
610
port_in_redirect off;
711

8-
# Support for URL/ → file.html
12+
add_header X-DNS-Prefetch-Control "off" always;
13+
add_header X-Frame-Options "SAMEORIGIN" always;
14+
add_header X-Download-Options "noopen" always;
15+
add_header X-Content-Type-Options "nosniff" always;
16+
add_header X-XSS-Protection "1; mode=block" always;
17+
18+
location = /favicon.ico {
19+
access_log off;
20+
log_not_found off;
21+
}
22+
23+
location = /robots.txt {
24+
access_log off;
25+
log_not_found off;
26+
}
27+
928
location ~ ^/(.*)/$ {
1029
try_files /$1.html =404;
1130
}
1231

13-
# GZIP settings
14-
gzip on;
15-
gzip_proxied any;
16-
gzip_comp_level 4;
17-
gzip_types text/css application/javascript image/svg+xml;
18-
19-
# Static assets
2032
location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ {
2133
try_files $uri $uri/ =404;
2234
}
2335

24-
# Main routing
2536
location / {
2637
try_files $uri.html $uri $uri/ @htmlext;
2738
}
2839

29-
# Direct .html access
3040
location ~ \.html$ {
3141
try_files $uri =404;
3242
}
3343

34-
# Rewrite to .html
3544
location @htmlext {
3645
rewrite ^(.*)$ $1.html last;
3746
}
3847

39-
# Liveness
4048
location = /live {
4149
access_log off;
4250
default_type application/json;
4351
return 200 '{"status":"healthy"}';
4452
}
4553

46-
# Readiness
4754
location = /ready {
4855
access_log off;
4956
default_type application/json;

0 commit comments

Comments
 (0)