Repository navigation
Expand file tree
/
Copy pathnginx.conf.local
More file actions
116 lines (99 loc) · 4.71 KB
/
Copy pathnginx.conf.local
File metadata and controls
116 lines (99 loc) · 4.71 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/json;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Mirror of the deployed CSP (see nginx.conf) so policy breakage shows up
# locally before QA. This config is static (no envsubst), so the Logto
# sources cover the tenants a local build may point to. No HSTS here:
# local setups may run plain HTTP.
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://widget.kapa.ai https://www.google.com https://www.gstatic.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://id.nethesis.it https://qa.id.nethesis.it https://*.logto.app https://www.google.com https://*.gstatic.com; font-src 'self' data:; connect-src 'self' https://id.nethesis.it https://qa.id.nethesis.it https://*.logto.app https://proxy.kapa.ai https://metrics.kapa.ai https://www.google.com; frame-src 'self' https://www.google.com; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'; form-action 'self' https://id.nethesis.it https://qa.id.nethesis.it https://*.logto.app" always;
server {
listen 8080;
server_name _;
# Health check endpoint for this proxy
location /health {
access_log off;
return 200 "nginx proxy healthy\n";
add_header Content-Type text/plain;
}
# Collect service routes - redirect without trailing slash
location = /collect/api {
return 301 /collect/api/;
}
location /collect/api/ {
rewrite ^/collect/api/(.*)$ /api/$1 break;
proxy_pass http://collect-full: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;
proxy_set_header X-Forwarded-Host $host;
# Timeouts
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
# Backend service routes - redirect without trailing slash
location = /backend/api {
return 301 /backend/api/;
}
# Bulk-import confirm creates one org per row in Logto and can run for
# tens of seconds; give just these endpoints a longer read timeout.
location ~ ^/backend/api/[^/]+/import/confirm$ {
rewrite ^/backend/api/(.*)$ /api/$1 break;
proxy_pass http://backend-full: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;
proxy_set_header X-Forwarded-Host $host;
proxy_connect_timeout 30s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
}
location /backend/api/ {
rewrite ^/backend/api/(.*)$ /api/$1 break;
proxy_pass http://backend-full: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;
proxy_set_header X-Forwarded-Host $host;
# Timeouts
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
# Frontend routes - everything else
location / {
proxy_pass http://frontend-full: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;
proxy_set_header X-Forwarded-Host $host;
# Timeouts
proxy_connect_timeout 30s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
}
}