This commit is contained in:
parent
7e4e76ce19
commit
42fca1fc41
7 changed files with 146 additions and 1 deletions
41
nginx.conf.template
Normal file
41
nginx.conf.template
Normal file
|
@ -0,0 +1,41 @@
|
|||
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;
|
||||
}
|
||||
}
|
Reference in a new issue