-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
49 lines (43 loc) · 1.88 KB
/
nginx.conf
File metadata and controls
49 lines (43 loc) · 1.88 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
# Map request Origin to allowed CORS origin.
# IMPORTANT: Before deploying to production, replace PRODUCTION_DOMAIN with your actual
# production domain (e.g. your-app.ondigitalocean.app or your custom domain).
# Do NOT use wildcard (*) in production.
map $http_origin $cors_origin {
default "";
"~^https://PRODUCTION_DOMAIN$" $http_origin;
}
server {
listen 8080;
server_name localhost;
root /web/dist;
index index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'" always;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# SPA routing - fallback to index.html for client-side routes
location / {
try_files $uri $uri/ /index.html;
}
# Proxy API requests to Spring Boot backend
# /api/imoveis -> http://localhost:8081/imoveis (strips the /api prefix)
location /api/ {
# Deixando o backend (Spring Security) lidar com todo o CORS preflight e headers
proxy_pass http://localhost:8081/;
proxy_http_version 1.1;
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;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
}