mirror of
https://github.com/CyberL1/dlinux-dashboard.git
synced 2025-01-22 01:19:18 -05:00
feat(proxy): use lua http module
This commit is contained in:
parent
62c6b8357d
commit
275a43fc18
@ -8,11 +8,11 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||||
proxy:
|
proxy:
|
||||||
image: openresty/openresty:alpine-fat
|
build: proxy
|
||||||
env_file: .env
|
env_file: .env
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
volumes:
|
volumes:
|
||||||
- ./proxy.conf:/etc/nginx/conf.d/proxy.conf.template
|
- ./proxy/proxy.conf.template:/etc/nginx/conf.d/proxy.conf.template
|
||||||
network_mode: host
|
network_mode: host
|
||||||
command: /bin/sh -c "sed 's/{PROXY_DOMAIN}/$PROXY_DOMAIN/' /etc/nginx/conf.d/proxy.conf.template > /etc/nginx/conf.d/proxy.conf && nginx -g 'daemon off;'"
|
command: /bin/sh -c "sed 's/{PROXY_DOMAIN}/$PROXY_DOMAIN/' /etc/nginx/conf.d/proxy.conf.template > /etc/nginx/conf.d/proxy.conf && nginx -g 'daemon off;'"
|
||||||
|
5
proxy/Dockerfile
Normal file
5
proxy/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
FROM openresty/openresty:alpine
|
||||||
|
|
||||||
|
RUN wget -O /usr/local/openresty/lualib/resty/http.lua https://github.com/ledgetech/lua-resty-http/raw/refs/heads/master/lib/resty/http.lua
|
||||||
|
RUN wget -O /usr/local/openresty/lualib/resty/http_connect.lua https://github.com/ledgetech/lua-resty-http/raw/refs/heads/master/lib/resty/http_connect.lua
|
||||||
|
RUN wget -O /usr/local/openresty/lualib/resty/http_headers.lua https://github.com/ledgetech/lua-resty-http/raw/refs/heads/master/lib/resty/http_headers.lua
|
@ -22,10 +22,10 @@ server {
|
|||||||
|
|
||||||
set $ip '';
|
set $ip '';
|
||||||
rewrite_by_lua_block {
|
rewrite_by_lua_block {
|
||||||
local shell = require("resty.shell")
|
local http = require("resty.http").new()
|
||||||
|
|
||||||
local ok, stdout, strerr, reason, status = shell.run("curl http://127.0.0.1:3000/containers/" .. ngx.var.container .. "/ip")
|
local res, err = http:request_uri("http://127.0.0.1:3000/containers/" .. ngx.var.container .. "/ip")
|
||||||
ngx.var.ip = stdout
|
ngx.var.ip = res.body
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_pass http://$ip:$port;
|
proxy_pass http://$ip:$port;
|
Loading…
x
Reference in New Issue
Block a user