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:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
proxy:
|
||||
image: openresty/openresty:alpine-fat
|
||||
build: proxy
|
||||
env_file: .env
|
||||
ports:
|
||||
- 80:80
|
||||
volumes:
|
||||
- ./proxy.conf:/etc/nginx/conf.d/proxy.conf.template
|
||||
- ./proxy/proxy.conf.template:/etc/nginx/conf.d/proxy.conf.template
|
||||
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;'"
|
||||
|
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 '';
|
||||
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")
|
||||
ngx.var.ip = stdout
|
||||
local res, err = http:request_uri("http://127.0.0.1:3000/containers/" .. ngx.var.container .. "/ip")
|
||||
ngx.var.ip = res.body
|
||||
}
|
||||
|
||||
proxy_pass http://$ip:$port;
|
Loading…
x
Reference in New Issue
Block a user