superfly / fly

Deploy app servers close to your users. Package your app as a Docker image, and launch it in 17 cities with one simple CLI.
https://fly.io
985 stars 48 forks source link

Using OpenResty for Authentication on Fly #290

Closed karllhughes closed 4 years ago

karllhughes commented 4 years ago

In #278 we talked about authentication being a good example for OpenResty, but it is a little more complex than just "getting started": https://github.com/zmartzone/lua-resty-openidc

So, I propose we do this article as a standalone topic after the introductory OpenResty one so we can reference it. This is sort of the 200-level content whereas the other one is more 100-level.

I'll add a rough outline later after I dig into this more.

codepope commented 4 years ago

OpenResty notes

The big thing here is structural, for users its probably better to talk about what you are deploying and then deploy it.

So...


How to Deploy OpenResty to Fly would be

Configuring the Dockerfile

Setting up the Nginx Configuration

noting you are listening on port 80

Then deploying on Fly with

flyctl init --port 80

(--port 80 sets the internal port to 80 so you can lose the section on editing services)

and then straight into deploying the app.


Other items:

To set up your reverse proxy, create a default.conf file in your root directory and add the following:

s/root/fly-openresty/

Suggest that the various iterations of default.conf are in the repository too, so create ratelimit-default.conf, redisapikeys-default.conf - saves cutting and pasting and leaves reference versions in the repo.

Fly will build and run your Docker image as a container on the edge, but you need to update your Dockerfile first.

Suggest "in a Firecracker VM on the edge" and "you'll need to create your Dockerfile file first" with the reordering.

codepope commented 4 years ago

Oh extra note... you can use flyctl open and flyctl open /api to view the app.

karllhughes commented 4 years ago

Thanks for the feedback @codepope, I'll update it this weekend and ping you when it's done.

karllhughes commented 4 years ago

@codepope updated this in the repo, here's the commit: https://github.com/fly-examples/openresty-basic/commit/bf0551d2c093872b18d54b7b07ea7e5a09b98596

Also, just realized this convo should be on the other OpenResty issue (#278) instead. This issue is for another possible future OpenResty article. 😬

Thanks again, let me know if I missed anything.

codepope commented 4 years ago

Well, and this should head over to community.fly.io but before we do that....

rather than go note by note, here's a PR - https://github.com/fly-examples/openresty-basic/pull/1

There was some non-linear activity in the process (create a docker file.... make a directory :) ) that I've fixed up.

karllhughes commented 4 years ago

Moved to Discord: https://community.fly.io/t/using-openresty-for-authentication-on-fly/91