https://github.com/niiknow/moonship
openresty dynamic multi-tenant CMS
https://github.com/niiknow/moonship
lua moonscript nginx ngx openresty
Last synced: 2 months ago
JSON representation
openresty dynamic multi-tenant CMS
- Host: GitHub
- URL: https://github.com/niiknow/moonship
- Owner: niiknow
- License: mit
- Created: 2017-07-02T05:18:47.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-03-04T18:20:50.000Z (over 6 years ago)
- Last Synced: 2025-08-13T02:48:55.553Z (10 months ago)
- Topics: lua, moonscript, nginx, ngx, openresty
- Language: Perl
- Homepage:
- Size: 360 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# moonship
> openresty dynamic multi-tenant CMS
# features
1. Auto Letsencrypt SSL with [lua-resty-auto-ssl](https://github.com/GUI/lua-resty-auto-ssl)
2. Content retrieval from the cloud
# stragegy
1. Browser hit server with some DNS that is CNAME to `tenant_name.yourserver.com`
2. We resolve tenant_name `base` to https://{some_cdn_host}/tenant_name/public
3. Template will be `{base}/templates/page.liquid` and `home (/)` page template will be `{base}/templates/index.liquid`
4. Content will be `{base}/contents/{slug}.json` or `index.json` for home page content.
5. Content can override with it's own template.
6. Assets (javascript/images/etc) are stored in {base}/assets
**Base on the stategy above**
* Auto-ssl is approved by determining if CNAME is valid. If Apex domain, then CNAME is lookup using `www` of the Apex domain. Redirects are handled by rule definition under https://{s3}/tenant_name/private/web.json - if web.json exists, then website has been correctly setup/activated. Example DNS `www.somesite.com CNAME yodawg.yourserver.com` identified that `yodawg` as your tenant name.
* Redirect rules must follow the schema loosely defined here: https://github.com/niiknow/mooncrafts/blob/master/lib/mooncrafts/resty/router.moon#L8 This library was originally made to handle *FaaS*, as a result, redirect rules can contain raw code that are capable of handling HTTP request.
**And we will need the following config**
```
# passthrough env vars
# AWS S3 config
env LETSENCRYPT_URL;
env AWS_DEFAULT_REGION;
env AWS_S3_KEY_ID;
env AWS_S3_ACCESS_KEY;
env AWS_S3_PATH;
# app stuff
env BASE_HOST; # the cname base host, i.e. yourserver.com
```
# build and run
osx, install lua/luarocks:
```
brew update
brew install lua
brew install openssl
make init
make test
```
# MIT