A Rate-Limiting HTTP Proxy(7)Docker and Deployment

lihy0 2017-06-01

ARate-LimitingHTTPProxy(7)DockerandDeployment

Weplantousesudotorunthecommandtostartthenginxonport80,weneedtolinkthecommandfirst

>sudoln-s/opt/openresty/nginx/sbin/nginx/usr/local/sbin/nginx

OnMACitworkswell,onRaspberryPI,ithasthisexceptionwhilerunningit

>sudonginx-p/opt/luaweb/dist/app-cconf/nginx.conf

nginx:[emerg]getgrnam("owner")failedin/opt/luaweb/dist/app/conf/nginx.conf:1

Solution:

Ichangethenginx.confandgetridofowner,itworks.

Afterinstallthethings,theURLforluarocksisasfollow:

/tool/luarocks/lib/luarocks/rocks

TheMakefilewillbuildthebinaryandpreparetheENV.

IMAGE=sillycat/public

TAG=raspberrypi-openresty

NAME=raspberrypi-openresty

app-init:

rm-frinstall

mkdirinstall

wgethttps://openresty.org/download/openresty-1.11.2.3.tar.gz-Pinstall/

wgethttp://luarocks.github.io/luarocks/releases/luarocks-2.4.2.tar.gz-Pinstall/

app-build:

./package.sh

tar-cvzf./dist/$(NAME)-1.0.tgz./luaweb-1.0

docker-context:

build:docker-context

dockerbuild-t$(IMAGE):$(TAG).

run:

dockerrun-d-p80:80--name$(NAME)$(IMAGE):$(TAG)

debug:

dockerrun-ti-p80:80--name$(NAME)$(IMAGE):$(TAG)/bin/bash

clean:

dockerstop${NAME}

dockerrm${NAME}

logs:

dockerlogs${NAME}

publish:

dockerpush${IMAGE}:${TAG}

fetch:

dockerpull${IMAGE}:${TAG}

Andpackage.shwillhelptobinarytheluascripts

#!/usr/bin/envbash

rm-rf./luaweb-1.0

mkdir-pluaweb-1.0/logs

mkdir-pluaweb-1.0/conf

cp-rfconf/nginx-prod.confluaweb-1.0/conf/nginx.conf

cp-rfhtmlluaweb-1.0

cp-rflualuaweb-1.0

cp-rflualibluaweb-1.0

luajit=/opt/openresty/luajit/bin/luajit

functioncompile(){

forfilein$1

do

iftest-f$file

then

$luajit-b$file$file

fi

done

}

compile"./luaweb-1.0/lua/web/*"

compile"./luaweb-1.0/lua/*"

Dockerfilewilldescribeallthestepstosetupimage

#SetupnginxinDocker

#PrepretheOS

FROMresin/rpi-raspbian:jessie

MAINTAINERCarlLuo<[email protected]>

ENVDEBIAN_FRONTENDnoninteractive

RUNapt-get-yupdate

RUNapt-getinstall-yapt-utils

RUNapt-get-ydist-upgrade

RUNapt-getinstall-ybuild-essentialgccmake

RUNapt-getinstall-ylibpcre3libpcre3-devzlib1g-devlibgcrypt11-dev

RUNapt-getinstall-ylibssl-devwgetunzip

#install

RUNmkdir-p/tool

RUNmkdir-p/install

#installopenresty

ADDinstall/openresty-1.11.2.3.tar.gz/install/

WORKDIR/install/openresty-1.11.2.3

RUN./configure--prefix=/tool/openresty

RUNmake

RUNmakeinstall

#installluarocks

ADDinstall/luarocks-2.4.2.tar.gz/install/

WORKDIR/install/luarocks-2.4.2

RUN./configure--with-lua="/tool/openresty/luajit"--lua-suffix="jit"--with-lua-include="/tool/openresty/luajit/include/luajit-2.1"

RUNmakebuild

RUNmakeinstall

#installdependencies

RUNluarocksinstallmd5

#installapp

RUNmkdir-p/share/

ADDdist/raspberrypi-openresty-1.0.tgz/share/

#starttheapplication

EXPOSE80

RUNmkdir-p/app/

ADDstart.sh/app/

WORKDIR/app/

CMD["./start.sh"]

RUNln-sf/dev/stdout/share/luaweb-1.0/logs/access.log

RUNln-sf/dev/stderr/share/luaweb-1.0/logs/error.log

start.shisthetriggertostartthenginxservice

#!/bin/sh-ex

cd/share/luaweb-1.0

/tool/openresty/nginx/sbin/nginx-p/share/luaweb-1.0-c/share/luaweb-1.0/conf/nginx.conf-g"daemonoff;"

References:

PreviousNote

http://www.ulos.pl/-configure-error-ssl-modules-require-the-openssl-library

https://serverfault.com/questions/657863/nginx-how-to-use-docker-log-collector-when-nginx-is-running-under-supervisord

相关推荐