mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:44:35 +03:00
improve webserver, add domain redirects (aliases), add tests and admin page ui to manage the config
- make builtin http handlers serve on specific domains, such as for mta-sts, so e.g. /.well-known/mta-sts.txt isn't served on all domains. - add logging of a few more fields in access logging. - small tweaks/bug fixes in webserver request handling. - add config option for redirecting entire domains to another (common enough). - split httpserver metric into two: one for duration until writing header (i.e. performance of server), another for duration until full response is sent to client (i.e. performance as perceived by users). - add admin ui, a new page for managing the configs. after making changes and hitting "save", the changes take effect immediately. the page itself doesn't look very well-designed (many input fields, makes it look messy). i have an idea to improve it (explained in admin.html as todo) by making the layout look just like the config file. not urgent though. i've already changed my websites/webapps over. the idea of adding a webserver is to take away a (the) reason for folks to want to complicate their mox setup by running an other webserver on the same machine. i think the current webserver implementation can already serve most common use cases. with a few more tweaks (feedback needed!) we should be able to get to 95% of the use cases. the reverse proxy can take care of the remaining 5%. nevertheless, a next step is still to change the quickstart to make it easier for folks to run with an existing webserver, with existing tls certs/keys. that's how this relates to issue #5.
This commit is contained in:
85
testdata/webserver/domains.conf
vendored
Normal file
85
testdata/webserver/domains.conf
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
Domains:
|
||||
mox.example:
|
||||
LocalpartCaseSensitive: false
|
||||
Accounts:
|
||||
mjl:
|
||||
Domain: mox.example
|
||||
Destinations:
|
||||
mjl: nil
|
||||
WebDomainRedirects:
|
||||
redir.mox.example: mox.example
|
||||
WebHandlers:
|
||||
-
|
||||
LogName: static
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/static/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebStatic:
|
||||
# This is run from the http package.
|
||||
Root: ../testdata/web
|
||||
ListFiles: true
|
||||
ResponseHeaders:
|
||||
X-Test: mox
|
||||
-
|
||||
LogName: nolist
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/nolist/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebStatic:
|
||||
StripPrefix: /nolist/
|
||||
# This is run from the http package.
|
||||
Root: ../testdata/web/static
|
||||
-
|
||||
LogName: httpsredir
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/tls/
|
||||
WebStatic:
|
||||
# This is run from the http package.
|
||||
Root: ../testdata/web/static
|
||||
-
|
||||
LogName: baseurlonly
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/baseurl/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebRedirect:
|
||||
BaseURL: https://tls.mox.example?q=1#fragment
|
||||
-
|
||||
LogName: pathonly
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/pathonly/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebRedirect:
|
||||
OrigPathRegexp: ^/pathonly/old/(.*)$
|
||||
ReplacePath: /pathonly/new/$1
|
||||
StatusCode: 307
|
||||
-
|
||||
LogName: baseurlpath
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/baseurlpath/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebRedirect:
|
||||
BaseURL: //other.mox.example?q=1#fragment
|
||||
OrigPathRegexp: ^/baseurlpath/old/(.*)$
|
||||
ReplacePath: /baseurlpath/new/$1
|
||||
# test code depends on these last two webhandlers being here.
|
||||
-
|
||||
LogName: strippath
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/strip/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebForward:
|
||||
StripPath: true
|
||||
# replaced while testing
|
||||
URL: http://127.0.0.1:1/a
|
||||
ResponseHeaders:
|
||||
X-Test: mox
|
||||
-
|
||||
LogName: nostrippath
|
||||
Domain: mox.example
|
||||
PathRegexp: ^/nostrip/
|
||||
DontRedirectPlainHTTP: true
|
||||
WebForward:
|
||||
# replaced while testing
|
||||
URL: http://127.0.0.1:1/a
|
||||
ResponseHeaders:
|
||||
X-Test: mox
|
13
testdata/webserver/mox.conf
vendored
Normal file
13
testdata/webserver/mox.conf
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
DataDir: data
|
||||
User: 1000
|
||||
LogLevel: trace
|
||||
Hostname: mox.example
|
||||
Listeners:
|
||||
local:
|
||||
IPs:
|
||||
- 0.0.0.0
|
||||
WebserverHTTP:
|
||||
Enabled: true
|
||||
Postmaster:
|
||||
Account: mjl
|
||||
Mailbox: postmaster
|
1
testdata/webserver/static/dir/hi.txt
vendored
Normal file
1
testdata/webserver/static/dir/hi.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
hi
|
1
testdata/webserver/static/index.html
vendored
Normal file
1
testdata/webserver/static/index.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
html
|
Reference in New Issue
Block a user