Opinionated nginx config generation for Deno.
Generate an nginx configuration to permanently redirect some routes from a.com to their new locations at b.com:
import ngx from "jsr:@char/ngx@0.2"; const redirects = { "/a": "https://b.com/new-a", "/b": "https://b.com/b-v2", }; const DOMAIN = "a.com"; const config = ngx("server", [ [ ngx.serverName(DOMAIN), ...ngx.listen(), ...ngx.letsEncrypt(DOMAIN), ], Object.entries(redirects).map(([path, uri]) => ngx(`location = ${path}`, [ `return 301 ${uri}` ]) ) ]) if (import.meta.main) console.log(config.build());
Add Package
deno add jsr:@char/ngx
Import symbol
import * as ngx from "@char/ngx";
---- OR ----
Import directly with a jsr specifier
import * as ngx from "jsr:@char/ngx";
Add Package
npx jsr add @char/ngx
Import symbol
import * as ngx from "@char/ngx";
Add Package
yarn dlx jsr add @char/ngx
Import symbol
import * as ngx from "@char/ngx";
Add Package
pnpm dlx jsr add @char/ngx
Import symbol
import * as ngx from "@char/ngx";
Add Package
bunx jsr add @char/ngx
Import symbol
import * as ngx from "@char/ngx";