Skip to content

ruby-no-kai/rko-router

Repository files navigation

rubykaigi.org router

nginx container deployed on AWS App Runner and served through CloudFront.

Detailed docs for RubyKaigi orgz: https://rubykaigi.esa.io/posts/1241

Deploy

Deployments are automatically performed on GitHub Actions on master branch after CI.

All resources except App Runner deployment is managed under Terraform (./tf).

Domains

Due to the quota of custom domains per App Runner service, the first hop on rko-router proxies a request to itself with correct Host header.

x-rko-host and x-rko-xfp headers are referenced as a Host and X-Forwarded-Proto header for the second hop.

These custom headers are assigned at CloudFront function (viewer-request) and implementation is at ./tf/cf_functions/src/viewreq.ts.

Run locally

docker build -t rko-router:latest .
docker run --rm --name rko-router --publish 127.0.0.1::8080 rko-router:latest
curl -H Host:rubykaigi.org http://$(docker port rko-router 8080)/
TARGET_HOST=http://$(docker port rko-router 8080) bundle exec rspec

Test

Test against production:

bundle exec rspec -fd ./spec

Test against alternate deployment:

bundle exec env TARGET_HOST=https://rko-router.herokuapp.com rspec -fd ./spec

AWS Login

https://rubykaigi.esa.io/posts/813