This repository has been archived on 2023-06-17. You can view files and clone it, but cannot push or open issues or pull requests.
unifiedpush-gotify/nginx.conf.template
samuel-p 42fca1fc41
All checks were successful
continuous-integration/drone/push Build is passing
initially added files
2021-02-23 22:57:36 +01:00

41 lines
1.3 KiB
Text

server {
listen 80;
resolver ${RESOLVER} ipv6=off;
location /_matrix/push/v1/notify {
set $target '';
if ($request_method = GET ) {
return 200 '{"gateway":"matrix"}';
}
access_by_lua_block {
local cjson = require("cjson")
ngx.req.read_body()
local body = ngx.req.get_body_data()
local parsedBody = cjson.decode(body)
ngx.var.target = parsedBody["notification"]["devices"][1]["pushkey"]
ngx.req.set_body_data(body)
}
proxy_set_header Content-Type application/json;
proxy_set_header Host $host;
proxy_pass $target;
proxy_ssl_server_name on;
}
location /UP {
access_by_lua_block{
ngx.req.read_body()
local req = ngx.req.get_body_data()
local newreq, n, err = ngx.re.gsub(req, '\\\\', '\\\\')
local newreq, n, err = ngx.re.gsub(newreq, '"', '\\"')
local newreq, n, err = ngx.re.gsub(newreq, "^", "{\"message\":\"")
local newreq, n, err = ngx.re.gsub(newreq, "$", "\"}")
ngx.req.set_body_data(newreq)
}
proxy_set_header Content-Type application/json;
proxy_set_header Host $host;
proxy_pass ${GOTIFY_URL}/message;
proxy_ssl_server_name on;
}
}