Nginx configuration file · 2642 bytes Raw Blame History
1 # tarmac.musicsian.com nginx configuration
2 #
3 # Setup (AlmaLinux/RHEL):
4 # sudo cp nginx.conf /etc/nginx/conf.d/tarmac.musicsian.com.conf
5 # sudo nginx -t
6 # sudo systemctl reload nginx
7 # sudo certbot --nginx -d tarmac.musicsian.com
8
9 server {
10 server_name tarmac.musicsian.com;
11
12 # Security headers
13 add_header X-Content-Type-Options nosniff;
14 add_header X-Frame-Options DENY;
15 add_header X-XSS-Protection "1; mode=block";
16 add_header Referrer-Policy "strict-origin-when-cross-origin";
17
18 # Gzip compression
19 gzip on;
20 gzip_vary on;
21 gzip_proxied any;
22 gzip_comp_level 6;
23 gzip_min_length 256;
24 gzip_types
25 text/plain
26 text/css
27 text/xml
28 text/javascript
29 application/json
30 application/javascript
31 application/xml
32 application/rss+xml
33 image/svg+xml;
34
35 # Logging
36 access_log /var/log/nginx/tarmac.access.log;
37 error_log /var/log/nginx/tarmac.error.log;
38
39 # Next.js application (reverse proxy)
40 location / {
41 proxy_pass http://127.0.0.1:3003;
42 proxy_http_version 1.1;
43 proxy_set_header Upgrade $http_upgrade;
44 proxy_set_header Connection 'upgrade';
45 proxy_set_header Host $host;
46 proxy_set_header X-Real-IP $remote_addr;
47 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
48 proxy_set_header X-Forwarded-Proto $scheme;
49 proxy_cache_bypass $http_upgrade;
50 proxy_read_timeout 60s;
51 }
52
53 # Static assets with long cache
54 location /_next/static {
55 proxy_pass http://127.0.0.1:3003;
56 proxy_http_version 1.1;
57 proxy_set_header Host $host;
58 expires 1y;
59 add_header Cache-Control "public, immutable";
60 }
61
62 # Sitemap and robots.txt — cache briefly, serve fast
63 location = /sitemap.xml {
64 proxy_pass http://127.0.0.1:3003;
65 proxy_http_version 1.1;
66 proxy_set_header Host $host;
67 expires 1d;
68 add_header Cache-Control "public";
69 }
70
71 location = /robots.txt {
72 alias /var/www/tarmac.musicsian.com/current/public/robots.txt;
73 expires 1w;
74 }
75
76 # Install script - serve directly with correct MIME type
77 location = /install.sh {
78 alias /var/www/tarmac.musicsian.com/current/public/install.sh;
79 default_type text/plain;
80 add_header Content-Type "text/plain; charset=utf-8";
81 }
82
83 # Favicon caching
84 location ~ ^/favicon\.(ico|png|svg)$ {
85 proxy_pass http://127.0.0.1:3003;
86 expires 1w;
87 }
88
89 # Block hidden files
90 location ~ /\. {
91 deny all;
92 }
93
94 listen 80;
95 listen [::]:80;
96 }