From 782e1d712518b68032dc47a69259205391fdb457 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Sat, 11 Feb 2023 16:43:39 -0500 Subject: [PATCH] [+] Add example config --- README.md | 4 +-- docs/examples/README.md | 6 ++++ docs/examples/arch.nginx.conf | 45 ++++++++++++++++++++++++++ docs/{ => examples}/example.nginx.conf | 0 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 docs/examples/README.md create mode 100644 docs/examples/arch.nginx.conf rename docs/{ => examples}/example.nginx.conf (100%) diff --git a/README.md b/README.md index c2850f3..0e5badb 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,12 @@ To update, simply do `git pull` and `yarn build` in the same directory. ### 2. Setup File API in Nginx -This module uses the json file listing api in nginx. If you already have an autoindex file server set up, you can make the following changes. If you're new to nginx, you can check out our [full example config](docs/example.nginx.conf). +This module uses the json file listing api in nginx. If you already have an autoindex file server set up, you can make the following changes. If you're new to nginx, you can check out our [example configs](docs/examples). The following example serves `/data/file-server` on http path `/` ```diff -- location ^~ / { +- location / { - alias "/data/file-server"; - fancyindex on; - fancyindex_exact_size off; diff --git a/docs/examples/README.md b/docs/examples/README.md new file mode 100644 index 0000000..eba8d25 --- /dev/null +++ b/docs/examples/README.md @@ -0,0 +1,6 @@ +### Nginx Examples + +Here are some of the example configurations using this module: + +* [arch.nginx.conf](./arch.nginx.conf): ArchLinux repository server +* [example.nginx.conf](./example.nginx.conf): A made-up example config \ No newline at end of file diff --git a/docs/examples/arch.nginx.conf b/docs/examples/arch.nginx.conf new file mode 100644 index 0000000..7872a87 --- /dev/null +++ b/docs/examples/arch.nginx.conf @@ -0,0 +1,45 @@ +# arch.hydev.org ArchLinux repository server +server +{ + listen 443 ssl; + listen [::]:443 ssl; + server_name arch.hydev.org; + + root /data/OS/ArchMirror/RISCV; + + # Serve a different file for your home page (if you want one) + location = / { + index extra/index.html; + } + + # If no file is found on any path, serve meowindex + location ^~ / { + try_files $uri /__meowindex__/index.html; + } + + # The api block + location ^~ /api { + alias /data/OS/ArchMirror/RISCV; + index DISABLE_INDEX_HTML_AUTO_MATCHING; + + autoindex on; + autoindex_format json; + add_header Access-Control-Allow-Origin *; + } + + # The MeowIndex web app block + location ^~ /__meowindex__ { + alias /etc/nginx/MeowIndex/dist; + + 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"; + + try_files $uri /__meowindex__/index.html; + } + + ssl_certificate /etc/letsencrypt/live/arch.hydev.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/arch.hydev.org/privkey.pem; +} \ No newline at end of file diff --git a/docs/example.nginx.conf b/docs/examples/example.nginx.conf similarity index 100% rename from docs/example.nginx.conf rename to docs/examples/example.nginx.conf