Skip to content

mod_unified_push: custom push_url does not work as ejabberd expects a domain from global hosts config #376

Description

@stratself

Probably relates to #367, but issue is a bit lengthy.

With this configuration:

hosts:
  - example.com
listen:
  -
    port: "5380"
    module: ejabberd_http
    tls: false
    request_handlers:
      /up: mod_unified_push
modules:
  mod_unified_push:
    push_url: "https://push.example.com:443/up" 

mod_unified_push doesn't work anymore. It can still register/unregister pushes on UP-Example, but clicking on "Send notifications" reveals that "An error occured."

Checking the logs, I can see the following issues:

<timestamp> [error] HTTP handler crashed: exception error: {module_not_loaded,mod_unified_push,<<"push.example.com">>}
   in function  gen_mod:get_module_opts/2 (src/gen_mod.erl:481)
   in call from gen_mod:get_module_opt/3 (src/gen_mod.erl:461)
   in call from mod_unified_push:get_jwk/1 (/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_unified_push/src/mod_unified_push.erl:236)
   in call from mod_unified_push:process/2 (/opt/ejabberd/.ejabberd-modules/sources/ejabberd-contrib/mod_unified_push/src/mod_unified_push.erl:83)
   in call from ejabberd_http:process/2 (src/ejabberd_http.erl:378)
   in call from ejabberd_http:process_request/1 (src/ejabberd_http.erl:506)
   in call from ejabberd_http:process_header/2 (src/ejabberd_http.erl:300)
   in call from ejabberd_http:parse_headers/1 (src/ejabberd_http.erl:225)

The same issue also occurs for push.@HOST@, where @HOST@ translates to example.com.

As a workaround, I've configured my reverse proxy (Caddy) to rewrite the hostname header to example.com.

https://push.example.com:443 {
    @unified-push {
        path /up*
    }
    handle @unified-push {
        reverse_proxy {
            to   http://ejabberd:5380
            header_up Host "muoi.me" ### <<< Add this
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions