File size: 3,293 Bytes
5d3c01b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
worker_processes auto;

events {
  worker_connections 1024;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;

  sendfile        on;
  keepalive_timeout  65;

  gzip on;
  gzip_min_length 1024;
  gzip_comp_level 5;
  gzip_types
    text/plain
    text/css
    text/javascript
    application/javascript
    application/json
    application/xml
    application/xml+rss
    image/svg+xml;

  server {
    listen 80;
    server_name _;

    root /usr/share/nginx/html;
    # The Vite build renames the SPA entry index.html -> dashboard.html
    # (dashboardHtmlOutputPlugin, non-desktop builds), matching the Vercel
    # rewrite of the catch-all route to /dashboard.html. Keep nginx in sync.
    index dashboard.html;

    location = /embed {
      include /etc/nginx/embed_security_headers.conf;
      try_files /embed.html =404;
      add_header Cache-Control "private, no-cache, must-revalidate";
    }

    location = /embed.html {
      include /etc/nginx/embed_security_headers.conf;
      try_files /embed.html =404;
      add_header Cache-Control "private, no-cache, must-revalidate";
    }

    location / {
      include /etc/nginx/security_headers.conf;
      try_files $uri $uri/ /dashboard.html;
      add_header Cache-Control "no-cache, no-store, must-revalidate";
    }

    location ~* ^/(assets|pro/assets|map-styles|data|textures|favico)/ {
      include /etc/nginx/security_headers.conf;
      try_files $uri =404;
      add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location = /offline.html {
      include /etc/nginx/security_headers.conf;
      add_header Cache-Control "public, max-age=86400";
    }

    location = /sw.js {
      include /etc/nginx/security_headers.conf;
      add_header Cache-Control "public, max-age=0, must-revalidate";
    }

    location = /manifest.webmanifest {
      include /etc/nginx/security_headers.conf;
      add_header Cache-Control "public, max-age=86400";
    }

    location ^~ /pro/assets/ {
      include /etc/nginx/security_headers.conf;
      try_files $uri =404;
      add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location ^~ /pro {
      include /etc/nginx/security_headers.conf;
      try_files $uri /pro/index.html;
      add_header Cache-Control "no-cache, no-store, must-revalidate";
    }

    location /api/ {
      include /etc/nginx/security_headers.conf;
      if ($request_method = 'OPTIONS') {
        add_header Access-Control-Allow-Origin "*" always;
        add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
        add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-WorldMonitor-Key" always;
        add_header Content-Length 0;
        return 204;
      }
      proxy_pass ${API_UPSTREAM};
      proxy_http_version 1.1;
      proxy_set_header Host $proxy_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;
      add_header Access-Control-Allow-Origin "*" always;
      add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
      add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-WorldMonitor-Key" always;
    }
  }
}