UP: Add common-proxies recipe.

This commit is contained in:
tastytea 2021-12-15 19:47:42 +01:00
parent c301203e0a
commit 84ed650ceb
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 105 additions and 32 deletions

View File

@ -28,6 +28,7 @@ toc: true
:url-gotify: https://gotify.net/ :url-gotify: https://gotify.net/
:url-push-examples: https://gotify.net/docs/pushmsg :url-push-examples: https://gotify.net/docs/pushmsg
:url-common-proxies: https://github.com/UnifiedPush/common-proxies :url-common-proxies: https://github.com/UnifiedPush/common-proxies
:url-common-proxies-install: https://github.com/UnifiedPush/common-proxies/blob/main/docs/install.md
I set up UnifiedPush because I wanted push notifications in FluffyChat without I set up UnifiedPush because I wanted push notifications in FluffyChat without
talking to Google. This was a bit more difficult than I imagined, so I'm writing talking to Google. This was a bit more difficult than I imagined, so I'm writing
@ -74,45 +75,16 @@ server creates and uses a directory called `data/` in its current path.
== Configure nginx == Configure nginx
You will need the link:{url-nginx-lua}[lua module] for nginx and I will not cover TLS certificates here, there are many good guides about that
link:{url-lua-cjson}[lua-cjson]. I will not cover TLS certificates here, there already.
are many good guides about that already.
[TIP]
If you don't want to deal with the lua stuff, there is also the
link:{url-common-proxies}[UnifiedPush Common-Proxies] project that provides a
rewrite proxy that does the same.
.Reinstall nginx with lua support and install lua-cjson in Gentoo
[source,shell]
--------------------------------------------------------------------------------
echo "www-servers/nginx NGINX_MODULES: http_lua" | sudo tee /etc/portage/package.use/gotify
echo "dev-lua/lua-cjson" | sudo tee -a /etc/portage/package.accept_keywords/gotify
sudo emerge -a1 www-servers/nginx
sudo emerge -a dev-lua/lua-cjson
sudo rc-service nginx restart
--------------------------------------------------------------------------------
You may have to tell nginx its lua module where to find lua-cjson. In my case I
had to add `lua_package_cpath "/usr/share/lua/5.1/?.so;;";` above the `server`
block. The `;;` means that the previous value of `lua_package_cpath` should be
appended.
Copy the link:{url-nginx}[configuration example], edit `server_name`, change Copy the link:{url-nginx}[configuration example], edit `server_name`, change
`listen 80;` to `listen [::]:443 ssl;` and `listen 443 ssl;` and change `listen 80;` to `listen [::]:443 ssl;` and `listen 443 ssl;` and change
`proxy_pass` to `http://[::1]:7777`. You don't need the `upstream` bit. `proxy_pass` to `http://[::1]:7777`. You don't need the `upstream` bit.
Copy the link:{url-nginx-up}[configuration example for UnifiedPush] into your
`server` block and change `proxy_pass` to `http://[::1]:7777/message`.
Copy the link:{url-nginx-matrix}[configuration example for Matrix] into your
`server` block and change `relay.example.tld` to your `server_name`.
.Your nginx configuration should look similar to this .Your nginx configuration should look similar to this
[source,nginx] [source,nginx]
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
lua_package_cpath "/usr/share/lua/5.1/?.so;;";
server { server {
listen 443 ssl; listen 443 ssl;
listen [::]:443 ssl; listen [::]:443 ssl;
@ -145,6 +117,107 @@ server {
proxy_send_timeout 1m; proxy_send_timeout 1m;
proxy_read_timeout 1m; proxy_read_timeout 1m;
} }
}
--------------------------------------------------------------------------------
Reload nginx and change the admin password in the web interface.
=== common-proxies method
This is the recommended method. link:{url-common-proxies}[UnifiedPush
Common-Proxies] is a rewrite-proxy that converts UnifiedPush messages to a
format that Gotify understands. If you're not on Gentoo, have a look at the
link:{url-common-proxies-install}[installation instructions] of the project.
.Install UnifiedPush common-proxies in Gentoo
[source,shell]
--------------------------------------------------------------------------------
echo -e "www-apps/up-common-proxies" | sudo tee -a /etc/portage/package.accept_keywords/gotify
sudo emerge -a www-apps/up-common-proxies
--------------------------------------------------------------------------------
Change the `listenAddr` and Gotify address in the config file
(`/etc/up-common-proxies/config.toml` on Gentoo) and add the UnifiedPush
locations to your nginx config. I will assume that common-proxies listens on
`[::1]:7778`.
.Your config.toml should look similar to this
[source,toml]
--------------------------------------------------------------------------------
listenAddr = "[::1]:7778"
verbose = true
[gateway]
[gateway.matrix]
enabled = true
[rewrite]
[rewrite.fcm]
enabled = false
[rewrite.gotify]
enabled = true
address = "[::1]:7777"
scheme = "http"
--------------------------------------------------------------------------------
.Start common-proxies in Gentoo and make it automatically start at boot
[source,shell]
--------------------------------------------------------------------------------
sudo rc-service up-common-proxies start
sudo rc-update add up-common-proxies
--------------------------------------------------------------------------------
.Your nginx configuration should look similar to this
[source,nginx]
--------------------------------------------------------------------------------
server {
# […]
location ~ ^/(FCM|UP|_matrix) {
proxy_pass http://[::1]:7778;
}
}
--------------------------------------------------------------------------------
Reload nginx.
=== Lua method
[WARNING]
The author of the lua-module warns that >=nginx-1.11.11 is still not an
officially supported target yet. You are on your own. Expect runtime failures,
memory leaks and other problems!
You will need the link:{url-nginx-lua}[lua module] for nginx and
link:{url-lua-cjson}[lua-cjson].
.Reinstall nginx with lua support and install lua-cjson in Gentoo
[source,shell]
--------------------------------------------------------------------------------
echo "www-servers/nginx NGINX_MODULES: http_lua" | sudo tee /etc/portage/package.use/gotify
echo "dev-lua/lua-cjson" | sudo tee -a /etc/portage/package.accept_keywords/gotify
sudo emerge -a1 www-servers/nginx
sudo emerge -a dev-lua/lua-cjson
sudo rc-service nginx restart
--------------------------------------------------------------------------------
You may have to tell nginx its lua module where to find lua-cjson. In my case I
had to add `lua_package_cpath "/usr/share/lua/5.1/?.so;;";` above the `server`
block. The `;;` means that the previous value of `lua_package_cpath` should be
appended.
Copy the link:{url-nginx-up}[configuration example for UnifiedPush] into your
`server` block and change `proxy_pass` to `http://[::1]:7777/message`.
Copy the link:{url-nginx-matrix}[configuration example for Matrix] into your
`server` block and change `relay.example.tld` to your `server_name`.
.Your nginx configuration should look similar to this
[source,nginx]
--------------------------------------------------------------------------------
lua_package_cpath "/usr/share/lua/5.1/?.so;;";
server {
# […]
location /UP { location /UP {
access_by_lua_block{ access_by_lua_block{
@ -184,7 +257,7 @@ server {
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Reload nginx and change the admin password in the web interface. Reload nginx.
== Use UnifiedPush == Use UnifiedPush