Update
This commit is contained in:
8
Makefile
8
Makefile
@@ -3,13 +3,13 @@ SRC_DIR := ./src
|
||||
|
||||
## DEPLOY PART
|
||||
build-image-dev:
|
||||
- sh ${DEPLOY_DIR}/image-build.sh dev
|
||||
- sh ${DEPLOY_DIR}/scripts/image-build.sh dev
|
||||
|
||||
build-image-prod:
|
||||
- sh ${DEPLOY_DIR}/image-build.sh
|
||||
- sh ${DEPLOY_DIR}/scripts/image-build.sh
|
||||
|
||||
push-image-dev:
|
||||
- sh ${DEPLOY_DIR}/image-push.sh dev
|
||||
- sh ${DEPLOY_DIR}/scripts/image-push.sh dev
|
||||
|
||||
push-image-prod:
|
||||
- sh ${DEPLOY_DIR}/image-push.sh
|
||||
- sh ${DEPLOY_DIR}/scripts/image-push.sh
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# errorfile 400 /etc/haproxy/errors/400.html
|
||||
# errorfile 401 /etc/haproxy/errors/401.html
|
||||
# errorfile 403 /etc/haproxy/errors/403.html
|
||||
# errorfile 404 /etc/haproxy/errors/404.html
|
||||
# errorfile 408 /etc/haproxy/errors/408.html
|
||||
# errorfile 429 /etc/haproxy/errors/429.html
|
||||
# errorfile 500 /etc/haproxy/errors/500.html
|
||||
# errorfile 502 /etc/haproxy/errors/502.html
|
||||
# errorfile 503 /etc/haproxy/errors/503.html
|
||||
# errorfile 504 /etc/haproxy/errors/504.html
|
||||
|
||||
global
|
||||
daemon
|
||||
maxconn 256
|
||||
|
||||
log 127.0.0.1 local0 debug
|
||||
|
||||
# lua-load /etc/haproxy/lua/jwt_auth.lua
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
timeout connect 5s
|
||||
timeout client 50s
|
||||
timeout server 50s
|
||||
|
||||
# frontend http-in
|
||||
# bind *:8443
|
||||
# mode http
|
||||
|
||||
# http-response set-header X-Custom-HAProxy-Header "rojter"
|
||||
# http-request lua.jwt_auth if { path_beg /api }
|
||||
# option httplog
|
||||
|
||||
# default_backend local
|
||||
|
||||
# backend local
|
||||
# mode http
|
||||
# server server 127.0.0.1:8080
|
||||
@@ -1,136 +0,0 @@
|
||||
-- package.path = "/usr/local/lib/lua/5.4/?.lua;" .. package.path
|
||||
|
||||
local jwt = require "resty/jwt"
|
||||
|
||||
function jwt_auth_req(txn)
|
||||
-- print_r(txn.http:req_get_headers()["Authorization"])
|
||||
|
||||
-- local auth_header = txn.http:req_get_headers()["authorization"]
|
||||
-- if not auth_header then
|
||||
-- txn.http:respond(401, "Unauthorized")
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
-- local token = auth_header:match("Bearer%s+(.+)")
|
||||
-- if not token then
|
||||
-- txn.http:respond(401, "Unauthorized")
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
-- -- Replace with your secret or public key
|
||||
-- local secret = "your-secret-key"
|
||||
|
||||
-- local jwt_obj = jwt:verify(secret, token)
|
||||
-- if not jwt_obj.verified then
|
||||
-- txn.http:respond(401, "Unauthorized")
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
-- -- Optionally, check claims, expiration, etc.
|
||||
-- return true
|
||||
end
|
||||
|
||||
function jwt_auth_res(txn)
|
||||
-- txn.http:res_add_header("Some-Header", "haproxy lua header")
|
||||
-- print_r(txn.http:res_get_headers())
|
||||
end
|
||||
|
||||
core.register_action("jwt_auth", { "http-req" }, jwt_auth_req, 0)
|
||||
core.register_action("jwt_auth", { "http-res" }, jwt_auth_res, 0)
|
||||
|
||||
-- Copyright 2016 Thierry Fournier
|
||||
|
||||
-- function color(index, str)
|
||||
-- return "\x1b[" .. index .. "m" .. str .. "\x1b[00m"
|
||||
-- end
|
||||
|
||||
-- function nocolor(index, str)
|
||||
-- return str
|
||||
-- end
|
||||
|
||||
-- function sp(count)
|
||||
-- local spaces = ""
|
||||
-- while count > 0 do
|
||||
-- spaces = spaces .. " "
|
||||
-- count = count - 1
|
||||
-- end
|
||||
-- return spaces
|
||||
-- end
|
||||
|
||||
-- function escape(str)
|
||||
-- local s = ""
|
||||
-- for i = 1, #str do
|
||||
-- local c = str:sub(i,i)
|
||||
-- ascii = string.byte(c, 1)
|
||||
-- if ascii > 126 or ascii < 20 then
|
||||
-- s = s .. string.format("\\x%02x", ascii)
|
||||
-- else
|
||||
-- s = s .. c
|
||||
-- end
|
||||
-- end
|
||||
-- return s
|
||||
-- end
|
||||
|
||||
-- function print_rr(p, indent, c, wr, hist)
|
||||
-- local i = 0
|
||||
-- local nl = ""
|
||||
|
||||
-- if type(p) == "table" then
|
||||
-- wr(c("33", "(table)") .. " " .. c("36", tostring(p)) .. " [")
|
||||
|
||||
-- for idx, value in ipairs(hist) do
|
||||
-- if value == p then
|
||||
-- wr(" " .. c("35", "/* recursion */") .. " ]")
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
-- hist[indent + 1] = p
|
||||
|
||||
-- mt = getmetatable(p)
|
||||
-- if mt ~= nil then
|
||||
-- wr("\n" .. sp(indent+1) .. c("31", "METATABLE") .. ": ")
|
||||
-- print_rr(mt, indent+1, c, wr, hist)
|
||||
-- end
|
||||
|
||||
-- for k,v in pairs(p) do
|
||||
-- if i > 0 then
|
||||
-- nl = "\n"
|
||||
-- else
|
||||
-- wr("\n")
|
||||
-- end
|
||||
-- wr(nl .. sp(indent+1))
|
||||
-- if type(k) == "number" then
|
||||
-- wr(c("32", tostring(k)))
|
||||
-- else
|
||||
-- wr("\"" .. c("32", escape(tostring(k))) .. "\"")
|
||||
-- end
|
||||
-- wr(": ")
|
||||
-- print_rr(v, indent+1, c, wr, hist)
|
||||
-- i = i + 1
|
||||
-- end
|
||||
-- if i == 0 then
|
||||
-- wr(" " .. c("35", "/* empty */") .. " ]")
|
||||
-- else
|
||||
-- wr("\n" .. sp(indent) .. "]")
|
||||
-- end
|
||||
|
||||
-- hist[indent + 1] = nil
|
||||
|
||||
-- elseif type(p) == "string" then
|
||||
-- wr(c("33", "(string)") .. " \"" .. c("36", escape(p)) .. "\"")
|
||||
-- else
|
||||
-- wr(c("33", "(" .. type(p) .. ")") .. " " .. c("36", tostring(p)))
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- function print_r(p, col, wr)
|
||||
-- if col == nil then col = true end
|
||||
-- if wr == nil then wr = function(msg) io.stdout:write(msg) end end
|
||||
-- local hist = {}
|
||||
-- if col == true then
|
||||
-- print_rr(p, 0, color, wr, hist)
|
||||
-- else
|
||||
-- print_rr(p, 0, nocolor, wr, hist)
|
||||
-- end
|
||||
-- wr("\n")
|
||||
-- end
|
||||
4
deploy/init.sh
Normal file
4
deploy/init.sh
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
git cl git@github.com:apache/apisix.git api-gatway/
|
||||
git cl git@github.com:apache/apisix-docker.git api-gateway/apisix/
|
||||
@@ -2,6 +2,7 @@
|
||||
# RUN IN REPO ROOT DIR !!
|
||||
|
||||
export IMAGE_NAME="git.ego.freeddns.org/egommerce/api-gateway"
|
||||
# export IMAGE_NAME="localhost:32000/egommerce/api-gateway"
|
||||
export BUILD_TIME=$(date +"%Y%m%d%H%M%S")
|
||||
|
||||
TARGET=${1:-latest}
|
||||
@@ -9,9 +10,9 @@ TARGET=${1:-latest}
|
||||
echo "Building: $IMAGE_NAME:$TARGET"
|
||||
if [ $TARGET = "dev" ]
|
||||
then
|
||||
docker build --build-arg BUILD_TIME --rm --no-cache -t "$IMAGE_NAME:dev" . # >/dev/null 2>&1
|
||||
docker build --rm --no-cache -t "$IMAGE_NAME:dev" . # >/dev/null 2>&1
|
||||
else
|
||||
docker build --build-arg BUILD_TIME --rm --cache-from "$IMAGE_NAME:$TARGET" -t "$IMAGE_NAME:$TARGET" . >/dev/null 2>&1
|
||||
docker build --rm --cache-from "$IMAGE_NAME:$TARGET" -t "$IMAGE_NAME:$TARGET" . >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
@@ -2,6 +2,7 @@
|
||||
# RUN IN REPO ROOT DIR !!
|
||||
|
||||
export IMAGE_NAME="git.ego.freeddns.org/egommerce/api-gateway"
|
||||
# export IMAGE_NAME="localhost:32000/egommerce/api-gateway"
|
||||
|
||||
TARGET=${1:-latest}
|
||||
|
||||
Reference in New Issue
Block a user