1. The problem I’m having:
I am trying to have all requests go to the maintenance page. Here is the code I have
(maintenance) {
@maintenance file /shared/pages/maintenance.html
handle @maintenance {
rewrite * /shared/pages/maintenance.html
file_server {
status 503
}
}
}
xyz.com {
encode gzip
# log {
# output file logs/site_access.log
# format json
# }
import maintenance
handle_path /zoomverify/* {
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Allow-Origin *
root * /zoomverify
file_server
}
root * /site
import redirected
}
2. Error messages and/or full log output:
The site is still loading. The maintenance page is not showing.
3. Caddy version:
v2.3
@francislavoie any ideas?
artknight:
3. Caddy version:
v2.3
That’s a pretty old version. Please upgrade to the latest.
artknight:
root * /site
Where is your file on disk? Is it in /site
?
Sorry, just checked the Caddy version is v2.5.2.
Additionally, I would upgrade to the latest but currently caddyserver.com does not compile the latest version + godaddy plugin.
No, it is in d:/shared/pages/maintenance.html
( fyi, adding the d:
did not make a difference )
You can build it yourself, it’s very easy: Build from source — Caddy Documentation
What do you mean by “the site” exactly? Show a request that does what you mean.
If you mean your /zoomverify
handle, the problem is likely because of directive sorting – directives (of the same kind) with a single path matcher are sorted higher than directives with any other kind of matcher.
You can see the effective order by adapting your Caddyfile to JSON with caddy adapt --pretty
.
You can use the route
directive to wrap the parts of config for which you want to enforce a particular order.
I edited my previous response. Sorry.
I would expect the maintenance page to show. However, the regular website is loading.
@francislavoie is it possible the maintenance mode is not getting activated/ triggered?
Then that’s your problem. The file directive is scoped to your configured root. You need to either change the root directive to match, or use the long-form for the file matcher to override the root. See the docs.
What is the long-form? Do you have an example?
@francislavoie here is my config file. What do I need to change?
(maintenance) {
@maintenance file d:/web/xyz.com/pages/maintenance.html
handle @maintenance {
rewrite * d:/web/xyz.com/pages/maintenance.html
file_server {
status 503
}
}
}
(redirected) {
@redirected {
not path /inc/* /cfc/* /js/* /css/* /shared/* /lucee/* /.well-known/* /zoomverify/*
path *
}
rewrite @redirected /index.cfm?{query}&path={path}
}
xyz.com {
encode gzip
# log {
# output file logs/site_access.log
# format json
# }
import maintenance
import ../security-headers.conf
import ../lucee.conf
handle_path /shared/* {
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Allow-Origin *
root * d:/web/xyz.com/shared
file_server
}
handle_path /.well-known/* {
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Allow-Origin *
root * d:/web/xyz.com/well-known
file_server
}
handle_path /zoomverify/* {
header Access-Control-Allow-Headers "Content-Type"
header Access-Control-Allow-Origin *
root * d:/web/xyz.com/zoomverify
file_server
}
root * d:/web/xyz.com
import redirected
}
@francislavoie Do you see anything wrong in my config. I did relocate the maintenance file into the root, as you had suggested. Would you please let me know if you see anything that needs changing in my config?
I don’t think you’ve done that.
Paths to files on disk are assembled by concatenating the root and the path together.
You set the root
to /site
and your file
matcher to /shared/pages/maintenance.html
, so it will look for a file at /site/shared/pages/maintenance.html
.
Where in the config are you seeing /site
?
FYI, the config is posted in my previous post ( not the original description )
system
(system)
Closed
April 27, 2023, 6:44pm
15
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.