-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
67 lines (57 loc) · 2.01 KB
/
nginx.conf
File metadata and controls
67 lines (57 loc) · 2.01 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
# Nginx configuration for Angular application
# Replace YOUR_SERVER_IP with your actual server IP
# Replace YOUR_API_SERVER_IP with your API server IP (if using proxy)
server {
listen 4200;
listen [::]:4200;
server_name _;
root /var/www/base-angular-app;
index index.html;
# Logs
access_log /var/log/nginx/base-angular-app.access.log;
error_log /var/log/nginx/base-angular-app.error.log;
# Redirect all routes to index.html (for Angular routing)
location / {
try_files $uri $uri/ /index.html;
}
# Cache static files
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Don't cache index.html
location = /index.html {
add_header Cache-Control "no-cache, no-store, must-revalidate";
expires 0;
}
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript
application/x-javascript application/xml+rss
application/json application/javascript;
# API proxy (optional, replace YOUR_API_SERVER_IP)
# Uncomment and configure if you need reverse proxy
# location /api/ {
# proxy_pass http://YOUR_API_SERVER_IP/api/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection 'upgrade';
# 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_cache_bypass $http_upgrade;
# }
# 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;
# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}