Public | Automated Build

Last pushed: 2 years ago
Short Description
Short description is empty for this repo.
Full Description


This is a Dockerfile for Openresty (ngx_openresty- on CenOS 7. redis2-nginx-module is configured for reverse proxy name resolving. Still in progress for minor improvements. Link to DockerHub: lowply/docker-openresty

Why CentOS?

There's no official OpenResty docker image for now. I chose CentOS 7 as base OS because simply I like it more than Ubuntu/Debian like distros.

Why Redis?

nginx tries to resolve hostname in proxy_pass directive, but it fails since it doesn't read /etc/hosts. Installing dnsmasq in the same host is one option for this problem, but redis is better for Docker use.

Why OpenResty?

Becaues this is great.

OpenResty is a full-fledged web application server by bundling the standard Nginx core, lots of 3rd-party Nginx modules, as well as most of their external dependencies

How to use


$ brew install redis

Pull the image

docker pull lowply/docker-openresty

Run Redis container first, update redis.conf if necessary

$ cat redis.conf
port 6379
loglevel verbose
logfile redis.log

$ docker run -d --name redis -p 6379:6379 -v $(pwd)/redis.conf:/etc/redis.conf -v $(pwd)/logs:/data redis redis-server /etc/redis.conf

Run your app container, named like (Used go made app in this example)

$ docker run -d --name -v /go/src/app/public lowply/

Run OpenResty container, linked to Redis and App container.

$ docker run -d --name openresty --link --link redis:redis -p 80:80 -v $(pwd)/logs/:/usr/local/openresty/nginx/logs lowply/openresty

Add domain as key and ip as value to redis, like A record

IPADDR=$(docker inspect ${DOMAIN} | jq -r [.][0][0]."NetworkSettings"."IPAddress")
$ redis-cli -h $(boot2docker ip) SET ${DOMAIN} "${IPADDR}"

Example docker ps output

$ docker ps
CONTAINER ID        IMAGE                                COMMAND                CREATED             STATUS              PORTS                    NAMES
664d093d2aa5        lowply/openresty:latest              "/bin/sh -c 'sbin/ng   40 minutes ago      Up 40 minutes>80/tcp       fixture.openresty
925decafaa26        lowply/            "go-wrapper run"       About an hour ago   Up About an hour    3000/tcp       
b5d322a16eb4        lowply/       "go-wrapper run"       2 hours ago         Up 2 hours          3000/tcp       
40c6de9d1573        redis:latest                         "/ redi   3 hours ago         Up 3 hours>6379/tcp   fixture.redis


  • Persistent data store for Redis container
  • Improve nginx.conf
Docker Pull Command
Source Repository