mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
improve http request handling for internal services and multiple domains
per listener, you could enable the admin/account/webmail/webapi handlers. but that would serve those services on their configured paths (/admin/, /, /webmail/, /webapi/) on all domains mox would be webserving, including any non-mail domains. so your www.example/admin/ would be serving the admin web interface, with no way to disabled that. with this change, the admin interface is only served on requests to (based on Host header): - ip addresses - the listener host name (explicitly configured in the listener, with fallback to global hostname) - "localhost" (for ssh tunnel/forwarding scenario's) the account/webmail/webapi interfaces are served on the same domains as the admin interface, and additionally: - the client settings domains, as optionally configured in each Domain in domains.conf. typically "mail.<yourdomain>". this means the internal services are no longer served on other domains configured in the webserver, e.g. www.example.org/admin/ will not be handled specially. the order of evaluation of routes/services is also changed: before this change, the internal handlers would always be evaluated first. with this change, only the system handlers for MTA-STS/autoconfig/ACME-validation will be evaluated first. then the webserver handlers. and finally the internal services (admin/account/webmail/webapi). this allows an admin to configure overrides for some of the domains (per hostname-matching rules explained above) that would normally serve these services. webserver handlers can now be configured that pass the request to an internal service: in addition to the existing static/redirect/forward config options, there is now an "internal" config option, naming the service (admin/account/webmail/webapi) for handling the request. this allows enabling the internal services on custom domains. for issue #160 by TragicLifeHu, thanks for reporting!
This commit is contained in:
13
testdata/web/domains.conf
vendored
13
testdata/web/domains.conf
vendored
@ -1,6 +1,12 @@
|
||||
Domains:
|
||||
mox.example:
|
||||
LocalpartCaseSensitive: false
|
||||
ClientSettingsDomain: mail.mox.example
|
||||
MTASTS:
|
||||
PolicyID: 1
|
||||
Mode: enforce
|
||||
MaxAge: 24h
|
||||
other.example: nil
|
||||
Accounts:
|
||||
mjl:
|
||||
Domain: mox.example
|
||||
@ -21,3 +27,10 @@ WebHandlers:
|
||||
ListFiles: true
|
||||
ResponseHeaders:
|
||||
X-Test: mox
|
||||
-
|
||||
LogName: adminoverride
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/admin/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebRedirect:
|
||||
BaseURL: http://redirect.example
|
||||
|
8
testdata/web/mox.conf
vendored
8
testdata/web/mox.conf
vendored
@ -8,6 +8,14 @@ Listeners:
|
||||
- 0.0.0.0
|
||||
WebserverHTTP:
|
||||
Enabled: true
|
||||
AdminHTTP:
|
||||
Enabled: true
|
||||
WebmailHTTP:
|
||||
Enabled: true
|
||||
MTASTSHTTPS:
|
||||
Enabled: true
|
||||
Port: 80
|
||||
NonTLS: true
|
||||
Postmaster:
|
||||
Account: mjl
|
||||
Mailbox: postmaster
|
||||
|
32
testdata/webserver/domains.conf
vendored
32
testdata/webserver/domains.conf
vendored
@ -69,6 +69,38 @@ WebHandlers:
|
||||
BaseURL: //other.mox.example?q=1#fragment
|
||||
OrigPathRegexp: ^/baseurlpath/old/(.*)$
|
||||
ReplacePath: /baseurlpath/new/$1
|
||||
-
|
||||
LogName: xadmin
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/xadmin/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebInternal:
|
||||
BasePath: /xadmin/
|
||||
Service: admin
|
||||
-
|
||||
LogName: xaccount
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/xaccount/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebInternal:
|
||||
BasePath: /xaccount/
|
||||
Service: account
|
||||
-
|
||||
LogName: xwebmail
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/xwebmail/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebInternal:
|
||||
BasePath: /xwebmail/
|
||||
Service: webmail
|
||||
-
|
||||
LogName: xwebapi
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/xwebapi/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebInternal:
|
||||
BasePath: /xwebapi/
|
||||
Service: webapi
|
||||
# test code depends on these last two webhandlers being here.
|
||||
-
|
||||
LogName: strippath
|
||||
|
2
testdata/webserver/mox.conf
vendored
2
testdata/webserver/mox.conf
vendored
@ -8,6 +8,8 @@ Listeners:
|
||||
- 0.0.0.0
|
||||
WebserverHTTP:
|
||||
Enabled: true
|
||||
AdminHTTP:
|
||||
Enabled: true
|
||||
Postmaster:
|
||||
Account: mjl
|
||||
Mailbox: postmaster
|
||||
|
Reference in New Issue
Block a user