openrestry

How to deploy openresty in AWS Elastic Beanstalk

Posted by

A Fast and Scalable Web Platform by Extending NGINX with LuaJIT – OpenResty.

Create an EB environment in AWS console

Select Preconfigured platform Docker, Application code use Sample application just for creating.

Prepare code for deploy test

nginx.conf:

worker_processes  1;
error_log logs/error.log;
events {
    worker_connections 1024;
}
http {
    server {
        listen 8080;
        location / {
            default_type text/html;
            content_by_lua_file main.lua;
        }
    }
}

main.lua:

ngx.say("<p>hello, world</p>")


Dockerfile:
FROM openresty/openresty
ADD app /app
ADD conf/nginx.conf /conf/nginx.conf
EXPOSE 8080
# Run it
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;", "-p", "/app", "-c", "/conf/nginx.conf"]

Files struct folder like this:

app
  --main.lua
  --logs
    -- log.txt
conf
 --nginx.cfg
Dockerfile

Compress app conf Dockerfile as a zip file, for example, deploy.zip

Deploy to eb

Upload and deploy it, wait for a second for deploy ok, you will see the result.