From 7d8b859a3a2257ae1395f9de94d4410095b12303 Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Wed, 13 Nov 2024 15:51:44 -0600 Subject: [PATCH] deployment instructions Signed-off-by: eternal-flame-AD --- README.md | 33 ++++++++++++++++++++++++++++++++- local.toml | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 local.toml diff --git a/README.md b/README.md index d5d114f..e31f78e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Work in progress! Currently to do: - [X] Cache-Control header - [X] Rate-limiting on local deployment (untested) - [X] Read config from Cloudflare +- [X] Timing and Rate-limiting headers (some not available on Cloudflare Workers) - [ ] Handle all possible panics reported by Clippy - [ ] Sandboxing the image rendering @@ -37,4 +38,34 @@ Image: [https://yumechi-no-kuni-proxy-worker.eternal-flame-ad.workers.dev/proxy/static.webp?url=https://upload.wikimedia.org/wikipedia/commons/a/ad/AES-AddRoundKey.svg](https://yumechi-no-kuni-proxy-worker.eternal-flame-ad.workers.dev/proxy/static.webp?url=https://upload.wikimedia.org/wikipedia/commons/a/ad/AES-AddRoundKey.svg) -![AES-AddRoundKey.svg](https://yumechi-no-kuni-proxy-worker.eternal-flame-ad.workers.dev/proxy/static.webp?url=https://upload.wikimedia.org/wikipedia/commons/a/ad/AES-AddRoundKey.svg) \ No newline at end of file +![AES-AddRoundKey.svg](https://yumechi-no-kuni-proxy-worker.eternal-flame-ad.workers.dev/proxy/static.webp?url=https://upload.wikimedia.org/wikipedia/commons/a/ad/AES-AddRoundKey.svg) + +## Setup and Deployment + +1. Clone this repository. Load the submodules with `git submodule update --init`. +2. Install Rust and Cargo, using [rustup](https://rustup.rs/) is recommended. + If you do not plan on deploying to Cloudflare Workers, you can remove the `rust-toolchain` file intended to get around [cloudflare/worker-rs#668](https://github.com/cloudflare/workers-rs/issues/668). Otherwise you may need to install that specific version of Rust by `rustup install install $(cat rust-toolchain)`. +3. IF deploying locally: + + 1. Edit `local.toml` to your liking. The documentations can be opened with `cargo doc --open`. + + 1. Test run with `cargo run --features env-local -- -c local.toml`. + + 1. Build with `cargo build --features env-local --profile release-local`. The built binary will be in `target/release/yumechi-no-kuni-proxy-worker`. + + 1. The only flag understood is `-c` for the configuration file. The configuration file is in TOML format. However, the `RUST_LOG` environment variable will change the log level. The log level is `info` by default if the environment variable is not set. + + IF deploying to Cloudflare Workers: + + 1. Add the wasm target with `rustup +$(cat rust-toolchain) target add wasm32-unknown-unknown`. + + 1. Have a working JS environment. + + 1. Install `wrangler` with you JS package manager of choice. See https://developers.cloudflare.com/workers/wrangler/install-and-update/. `npx` also works. + + 1. Edit `wrangler.toml` to your liking. Everything in the `[vars]` section maps directly into the `config` section of the TOML configuration file. + + 1. Test locally with `wrangler dev`. + + 1. Deploy with `wrangler deploy --outdir bundled/`. + diff --git a/local.toml b/local.toml new file mode 100644 index 0000000..5af7180 --- /dev/null +++ b/local.toml @@ -0,0 +1,19 @@ +listen = "127.0.0.1:3000" +enable_cache = false +index_redirect = { permanent = false, url = "https://mi.yumechi.jp/" } +allow_unknown = false + +[fetch] +addr_family = "both" +allow_http = false +via = "yumechi-no-kuni-proxy-worker" +user_agent = "Yumechi-no-Kuni-Proxy-Worker" + +[post_process] +enable_redirects = false +normalization = "lazy" +allow_svg_passthrough = true + +[rate_limit] +replenish_every = 2000 +burst = 32 \ No newline at end of file