77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_comp_level 6;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/xml
|
|
text/javascript
|
|
application/javascript
|
|
application/xml+rss
|
|
application/json
|
|
image/svg+xml;
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options DENY;
|
|
add_header X-Content-Type-Options nosniff;
|
|
add_header X-XSS-Protection "1; mode=block";
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
|
|
|
# Handle Vue Router history mode
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Cache static assets
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
access_log off;
|
|
}
|
|
|
|
# API proxy to backend on localhost (for CI/standalone frontend deployments)
|
|
location /api/ {
|
|
proxy_pass http://127.0.0.1:18888;
|
|
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_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# CORS headers passthrough
|
|
proxy_pass_header Access-Control-Allow-Origin;
|
|
proxy_pass_header Access-Control-Allow-Methods;
|
|
proxy_pass_header Access-Control-Allow-Headers;
|
|
proxy_pass_header Access-Control-Allow-Credentials;
|
|
|
|
# Logs for debugging
|
|
access_log /var/log/nginx/api_proxy.log;
|
|
error_log /var/log/nginx/api_proxy_error.log;
|
|
}
|
|
|
|
# Disable access to hidden files
|
|
location ~ /\. {
|
|
deny all;
|
|
access_log off;
|
|
log_not_found off;
|
|
}
|
|
|
|
# Custom error pages
|
|
error_page 404 /index.html;
|
|
error_page 500 502 503 504 /index.html;
|
|
}
|
|
|
|
|