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

41 lines
1.2 KiB
Text
Raw Permalink Normal View History

2021-02-23 21:57:36 +00:00
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{
2021-03-19 19:33:40 +00:00
local json = require("cjson")
2021-02-23 21:57:36 +00:00
ngx.req.read_body()
local req = ngx.req.get_body_data()
2021-03-19 19:33:40 +00:00
local newreq = { ["message"] = req }
local body = json.encode(newreq)
ngx.req.set_body_data(body)
2021-02-23 21:57:36 +00:00
}
proxy_set_header Content-Type application/json;
proxy_set_header Host $host;
proxy_pass ${GOTIFY_URL}/message;
proxy_ssl_server_name on;
}
}