char/ngx
opinionated nginx config generation for Deno
git clone https://git.t4t.associates/char/ngx
257f894
main
files
| .editorconfig | 148 B |
| README.md | 639 B |
| deno.json | 95 B |
| ngx.ts | 4.8 KiB |
ngx
Opinionated nginx config generation for Deno.
Example
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 ());