1- geo $dollar_sign {
2- default "$";
3- }
4-
51map $http_upgrade $connection_upgrade {
62 default upgrade;
73 "" close;
@@ -28,8 +24,9 @@ server {
2824 return 200 "ok\n";
2925 }
3026
31- location /api/ {
27+ location /dashboard/ api/ {
3228 set $api_upstream api:8000;
29+ rewrite ^/dashboard/api(/.*)$ /api$1 break;
3330 proxy_pass http://$api_upstream;
3431 proxy_http_version 1.1;
3532 proxy_set_header Host $host;
@@ -39,8 +36,9 @@ server {
3936 proxy_read_timeout 60s;
4037 }
4138
42- location /health {
39+ location = /dashboard /health {
4340 set $api_upstream api:8000;
41+ rewrite ^ /health break;
4442 proxy_pass http://$api_upstream;
4543 proxy_http_version 1.1;
4644 proxy_set_header Host $host;
@@ -49,59 +47,31 @@ server {
4947 proxy_set_header X-Forwarded-Proto $scheme;
5048 }
5149
52- location = /teslamate {
53- return 301 /teslamate /;
50+ location = /dashboard {
51+ return 301 /dashboard /;
5452 }
5553
56- location /teslamate/ {
57- set $teslamate_upstream teslamate:4000;
58- rewrite ^/teslamate/(.*)$ /$1 break;
59- proxy_pass http://$teslamate_upstream;
60- proxy_http_version 1.1;
61- proxy_set_header Accept-Encoding "";
62- proxy_set_header Host $host;
63- proxy_set_header X-Real-IP $remote_addr;
64- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
65- proxy_set_header X-Forwarded-Proto $scheme;
66- proxy_set_header X-Forwarded-Prefix /teslamate;
67- proxy_set_header Upgrade $http_upgrade;
68- proxy_set_header Connection $connection_upgrade;
69- proxy_read_timeout 3600s;
70- proxy_redirect / /teslamate/;
71- sub_filter_once off;
72- sub_filter_types *;
73- sub_filter 'href="/' 'href="/teslamate/';
74- sub_filter 'src="/' 'src="/teslamate/';
75- sub_filter 'action="/' 'action="/teslamate/';
76- sub_filter '"/live' '"/teslamate/live';
77- sub_filter '"/js/' '"/teslamate/js/';
78- sub_filter 'url(/' 'url(/teslamate/';
79- sub_filter 'baseUrl:window.location.origin' 'baseUrl:window.location.origin+"/teslamate"';
80- sub_filter 'url:this.redirect?void 0:this.href||void 0' 'url:this.redirect?void 0:(this.href!==null?this.href.replace("/teslamate","/"):this.href)||void 0';
81- sub_filter 'onRedirect({to:o,flash:r}){this.liveSocket.redirect(o,r)}' 'onRedirect({to:o,flash:r}){this.liveSocket.redirect(o.replace(o.startsWith("/")?/^\//gm:/\/${dollar_sign}/gm, "/teslamate/"),r)}';
54+ location /dashboard/assets/ {
55+ try_files $uri =404;
56+ expires 30d;
57+ add_header Cache-Control "public, max-age=2592000, immutable";
58+ }
59+
60+ location /dashboard/ {
61+ try_files $uri $uri/ /dashboard/index.html;
8262 }
8363
84- location /live/websocket {
64+ location / {
8565 set $teslamate_upstream teslamate:4000;
8666 proxy_pass http://$teslamate_upstream;
8767 proxy_http_version 1.1;
88- proxy_set_header Host $host ;
68+ proxy_set_header Host $http_host ;
8969 proxy_set_header X-Real-IP $remote_addr;
9070 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
9171 proxy_set_header X-Forwarded-Proto $scheme;
92- proxy_set_header X-Forwarded-Prefix /teslamate ;
72+ proxy_set_header X-Forwarded-Host $http_host ;
9373 proxy_set_header Upgrade $http_upgrade;
9474 proxy_set_header Connection $connection_upgrade;
9575 proxy_read_timeout 3600s;
9676 }
97-
98- location /assets/ {
99- try_files $uri =404;
100- expires 30d;
101- add_header Cache-Control "public, max-age=2592000, immutable";
102- }
103-
104- location / {
105- try_files $uri /index.html;
106- }
10777}
0 commit comments