[+] Better deploy guide
This commit is contained in:
@@ -24,24 +24,22 @@ This module uses the json file listing api in nginx. If you already have an auto
|
|||||||
|
|
||||||
The following example serves `/data/file-server` on http path `/`
|
The following example serves `/data/file-server` on http path `/`
|
||||||
|
|
||||||
```diff
|
```nginx.conf
|
||||||
- location / {
|
server_name your.domain.com;
|
||||||
- alias "/data/file-server";
|
|
||||||
- fancyindex on;
|
|
||||||
- fancyindex_exact_size off;
|
|
||||||
- }
|
|
||||||
|
|
||||||
+ location ^~ /api {
|
root /your/file/server/location;
|
||||||
+ alias "/data/file-server";
|
|
||||||
+ autoindex on;
|
# Serve an index file for your home page (if you want one)
|
||||||
+ autoindex_format json;
|
location = / {
|
||||||
+ add_header Access-Control-Allow-Origin *;
|
index index.html;
|
||||||
+ }
|
}
|
||||||
|
|
||||||
|
include "/etc/nginx/MeowIndex/docs/nginx.conf";
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Setup File Listing UI
|
### 3. Setup File Listing UI
|
||||||
|
|
||||||
You can setup the file listing web UI in three different ways.
|
You can setup the file listing web UI in two different ways.
|
||||||
|
|
||||||
* If you want to deploy on a standalone domain (e.g. `https://files.example.com`), follow Option 1.
|
* If you want to deploy on a standalone domain (e.g. `https://files.example.com`), follow Option 1.
|
||||||
* If you want to deploy on a sub-path of an existing domain (e.g. `https://example.com/files`), follow Option 2.
|
* If you want to deploy on a sub-path of an existing domain (e.g. `https://example.com/files`), follow Option 2.
|
||||||
@@ -50,39 +48,30 @@ You can setup the file listing web UI in three different ways.
|
|||||||
|
|
||||||
Add the following location block to the same server block as your file api.
|
Add the following location block to the same server block as your file api.
|
||||||
|
|
||||||
```nginx.conf
|
```diff
|
||||||
location ^~ / {
|
- location / {
|
||||||
alias /etc/nginx/MeowIndex/dist;
|
- fancyindex on;
|
||||||
|
- fancyindex_exact_size off;
|
||||||
|
- }
|
||||||
|
|
||||||
# Use sub_filter to configure the app
|
+ # If no file is found on any path, serve meowindex
|
||||||
sub_filter_types application/javascript;
|
+ location / {
|
||||||
sub_filter_once on;
|
+ try_files $uri /__meowindex__/index.html;
|
||||||
sub_filter "{HOST-PLACEHOLDER}" "/api";
|
+ }
|
||||||
|
|
||||||
# Serve index.html on other 404 paths as well
|
|
||||||
try_files $uri $uri/ /index.html;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Option 2: Deploying to a path of an existing domain
|
#### Option 2: Deploying to a path of an existing domain
|
||||||
|
|
||||||
Add the following location block to the same server block as your file api, and replace the following:
|
Add the following location block to the same server block as your file api, and replace `/data` with the path you want to deploy to.
|
||||||
|
|
||||||
* Replace `/data` with the path you want to deploy to
|
```diff
|
||||||
* Replace `/api` with your api endpoint
|
- location /data {
|
||||||
|
- fancyindex on;
|
||||||
|
- fancyindex_exact_size off;
|
||||||
|
- }
|
||||||
|
|
||||||
```nginx.conf
|
+ # If no file is found on any path, serve meowindex
|
||||||
location ^~ /data {
|
+ location /data {
|
||||||
alias /etc/nginx/MeowIndex/dist;
|
+ try_files $uri /__meowindex__/index.html;
|
||||||
|
+ }
|
||||||
# Use sub_filter to configure the app
|
|
||||||
sub_filter_types application/javascript;
|
|
||||||
sub_filter_once off;
|
|
||||||
sub_filter "{DEPLOY-PATH-PLACEHOLDER}" "/data";
|
|
||||||
sub_filter "{HOST-PLACEHOLDER}" "/api";
|
|
||||||
sub_filter "\"/assets" "\"/data/assets";
|
|
||||||
|
|
||||||
# Serve index.html on other 404 paths as well
|
|
||||||
try_files $uri $uri/ /data/index.html;
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# The MeowIndex web app block
|
||||||
|
location /__meowindex__ {
|
||||||
|
alias /etc/nginx/MeowIndex/dist;
|
||||||
|
|
||||||
|
# Use sub_filter to configure the app
|
||||||
|
sub_filter_types application/javascript;
|
||||||
|
sub_filter_once off;
|
||||||
|
sub_filter "{DEPLOY-PATH-PLACEHOLDER}" "/__meowindex__";
|
||||||
|
sub_filter "{HOST-PLACEHOLDER}" "/api";
|
||||||
|
sub_filter "\"/assets" "\"/__meowindex__/assets";
|
||||||
|
|
||||||
|
# Serve index.html on other 404 paths as well
|
||||||
|
try_files $uri /__meowindex__/index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# The api block
|
||||||
|
location /api {
|
||||||
|
rewrite ^/api(/.*)$ $1 break;
|
||||||
|
index DISABLE_INDEX_HTML_AUTO_MATCHING;
|
||||||
|
|
||||||
|
autoindex on;
|
||||||
|
autoindex_format json;
|
||||||
|
add_header Access-Control-Allow-Origin *;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user