Browse Source

fixed two bugs:

* config was not loaded, because I used load in the wrong way
* I broke the get_req_ip() function in the past (but I don't know why...)
master
Sebastian 1 year ago
parent
commit
42a457f5b1
Signed by: imo GPG Key ID: AFA10CBFE4391C0C
  1. 2
      README.md
  2. 16
      wmia.lua

2
README.md

@ -16,7 +16,7 @@ Currently it is recommand to run this service behind nginx.
### Docker installation
There is an docker image, which is the easiest way to run this service. Just do
There is a [docker image](https://hub.docker.com/r/imolein/wmia), which is the easiest way to run this service. Just do
```
docker run -it -d --rm --init -p 127.0.0.1:9090:9090 imolein/wmia:latest

16
wmia.lua

@ -60,11 +60,9 @@ local function load_config(cfg)
if exists(cfg) then
logger('INFO', 'Loading config from file %s', cfg)
local fh = assert(io.open(cfg))
local content = fh:read('*a')
fh:close()
local fn = assert(load(content, cfg))
conf = fn()
assert(load(fh:read(2048), cfg, nil, conf))()
fh:close()
end
apply_env_config(conf)
@ -103,11 +101,13 @@ end
-- preffer the X-Real-IP over X-Forwared-For if
-- proxied
local function get_req_ip(con_ip, req_headers)
local ip = con_ip == '127.0.0.1'
and (req_headers:has('x-real-ip') or req_headers:has('x-forwarded-for'))
or con_ip
local ip
if con_ip == '127.0.0.1' then
ip = req_headers:get('x-real-ip') or req_headers:get('x-forwarded-for')
end
return ip
return ip or con_ip
end
-- opens and read the index.html, replaces the

Loading…
Cancel
Save