浏览代码

Add rewrites for json api

Bob Mottram 6 年前
父节点
当前提交
b597ac0971
共有 1 个文件被更改,包括 26 次插入0 次删除
  1. 26
    0
      src/freedombone-utils-web

+ 26
- 0
src/freedombone-utils-web 查看文件

@@ -1163,6 +1163,19 @@ function install_web_local_user_interface {
1163 1163
       echo '';
1164 1164
       echo '  access_log /dev/null;';
1165 1165
       echo '  error_log /dev/null;';
1166
+      echo '';
1167
+      echo '  location /icons {';
1168
+      echo '    autoindex on;';
1169
+      echo '    break;';
1170
+      echo '  }';
1171
+      echo '';
1172
+      echo '  rewrite ^/plinth/(.*)$ /api.json last;';
1173
+      echo '';
1174
+      echo '  location / {';
1175
+      echo "    root /var/www/${local_hostname}/htdocs/plinth;";
1176
+      echo '    index api.json /api.json;';
1177
+      echo "    error_page 405 = \$uri;";
1178
+      echo '  }';
1166 1179
       echo '}';
1167 1180
       echo '';
1168 1181
       echo 'server {';
@@ -1180,6 +1193,19 @@ function install_web_local_user_interface {
1180 1193
     nginx_security_options "${local_hostname}"
1181 1194
 
1182 1195
     { echo '  add_header Strict-Transport-Security max-age=0;';
1196
+      echo '';
1197
+      echo '  location /icons {';
1198
+      echo '    autoindex on;';
1199
+      echo '    break;';
1200
+      echo '  }';
1201
+      echo '';
1202
+      echo '  rewrite ^/plinth/(.*)$ /api.json last;';
1203
+      echo '';
1204
+      echo '  location / {';
1205
+      echo "    root /var/www/${local_hostname}/htdocs/plinth;";
1206
+      echo '    index api.json /api.json;';
1207
+      echo "    error_page 405 = \$uri;";
1208
+      echo '  }';
1183 1209
       echo '}'; } >> "$nginx_file"
1184 1210
 
1185 1211
     if [ ! -f "/etc/ssl/certs/${local_hostname}.crt" ]; then