mirror of
https://github.com/CyberL1/dlinux-dashboard.git
synced 2025-06-28 16:19:43 -04:00
feat(proxy): use lua http module
This commit is contained in:
36
proxy/proxy.conf.template
Normal file
36
proxy/proxy.conf.template
Normal file
@ -0,0 +1,36 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name {PROXY_DOMAIN};
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name "~^(port-(?<port>.*)\.)?(?<container>.*)\.{PROXY_DOMAIN}";
|
||||
|
||||
location / {
|
||||
if ($port = "") {
|
||||
set $port "80";
|
||||
}
|
||||
|
||||
set $ip '';
|
||||
rewrite_by_lua_block {
|
||||
local http = require("resty.http").new()
|
||||
|
||||
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;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user