dug
(Doug Fredericks)
July 23, 2022, 1:32am
1
1. Caddy version (caddy version
):
2.5.2
2. How I run Caddy:
On a VPS
a. System environment:
Debian 10
b. Command:
Paste command here.
c. Service/unit/compose file:
Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.
d. My complete Caddyfile or JSON config:
matrix.dougfredericks.space {
reverse_proxy /_matrix/* http://localhost:8008
reverse_proxy /_synapse/client/* http://localhost:8008
}
dougfredericks.space:8448 {
reverse_proxy http://localhost:8008
}
chat.dougfredericks.space {
header {
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Robots-Tag "noindex, noarchive, nofollow"
}
root * /opt/element
file_server
}
3. The problem Iām having:
Iām running a matrix-synapse server on a digital-ocean server. I used their ā1-clickā option to set it up. Iām not very familiar with Caddy unfortunately.
I need to have a ā.well-knownā directory added to the configuration and of course added to a directory on my server. If this were apache, it would set it up to go in /var/www, but with Caddy I donāt know how to create that direction.
4. Error messages and/or full log output:
āThis server failed the āwell-knownā check. Make sure the server is configured correctly.ā
5. What I already tried:
Found answers for other web servers, just not for Caddy
6. Links to relevant resources:
Matrix homeservers use the Federation APIs (also known as server-server APIs) to communicate with each other. Homeservers use these APIs to push messages to each other in real-time, to retrieve historic messages from each other, and to query profile...
1 Like
matt
(Matt Holt)
July 23, 2022, 1:48am
2
I just barely updated the docs for Synapse with regards to Caddy this week (plus I set it up myself). Itās super easy. Let me get back to you when Iām not mobile.
1 Like
Hi
Have a look at Nginx return directive in caddy -- return json - #3 by IndeedNotJames .
You technically donāt need the dougfredericks.space:8448
if you delegate via .well-known/matrix/server
to { "m.server": "matrix.dougfredericks.space:443" }
.
You would need to customize the handle_path
from the linked post and add something like
dougfredericks.space {
handle_path /.well-known/matrix/* {
<all the other things>
}
}
to your Caddyfile and you should be all set!
Hope that helps, but feel free to ask more questions
3 Likes
matt
(Matt Holt)
July 23, 2022, 5:34pm
4
Hereās my docs contribution to Synapse, still waiting to be merged:
matrix-org:develop
ā mholt:patch-1
opened 05:37PM - 20 Jul 22 UTC
Improve/simplify Caddy examples. Remove Caddy v1 (has long been EOL'ed)
### P⦠ull Request Checklist
* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog file](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should:
- Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
- Use markdown where necessary, mostly for `code blocks`.
- End with either a period (.) or an exclamation mark (!).
- Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
* [x] Pull request includes a [sign off](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#sign-off)
* [x] [Code style](https://matrix-org.github.io/synapse/latest/code_style.html) is correct
(run the [linters](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
Example from that PR:
example.com {
header /.well-known/matrix/* Content-Type application/json
header /.well-known/matrix/* Access-Control-Allow-Origin *
respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}`
respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.example.com"},"m.identity_server":{"base_url":"https://identity.example.com"}}`
}
matrix.example.com {
reverse_proxy /_matrix/* localhost:8008
reverse_proxy /_synapse/client/* localhost:8008
}
You do not need a file server at all. The well-known āfilesā can be hard-coded into your config very easily.
2 Likes
dug
(Doug Fredericks)
July 23, 2022, 5:40pm
5
Works!
Side note for when I inevitably google this in a year or so : I added this to my matrix-synapse yaml config file:
serve_server_wellknown: true
And revised by Caddyfile to:
matrix.dougfredericks.space {
reverse_proxy /_matrix/* http://localhost:8008
reverse_proxy /_synapse/client/* http://localhost:8008
}
dougfredericks.space:8448 {
reverse_proxy http://localhost:8008
}
(matrix-well-known-header) {
# Headers
header Access-Control-Allow-Origin "*"
header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"
header Content-Type "application/json"
}
dougfredericks.space {
handle /.well-known/matrix/server {
import matrix-well-known-header
respond `{"m.server":"matrix.dougfredericks.space:443"}`
}
handle /.well-known/matrix/client {
import matrix-well-known-header
respond `{"m.homeserver":{"base_url":"https://matrix.dougfredericks.space"},"m.identity_server":{"base_url":"https://identity.dougfredericks.space"}}`
}
}
chat.dougfredericks.space {
header {
X-Frame-Options "SAMEORIGIN"
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Robots-Tag "noindex, noarchive, nofollow"
}
root * /opt/element
file_server
}
Helpful link:
https://matrix-org.github.io/synapse/develop/reverse_proxy.html
matt
(Matt Holt)
July 23, 2022, 7:22pm
6
Cool, glad you got it working. Note that itās more complex than it has to be, as thatās using the old/current version of the docs. Refer to my PR linked above for something simpler. (If it doesnāt work, let me know)
1 Like
system
(system)
Closed
August 22, 2022, 1:33am
7
This topic was automatically closed after 30 days. New replies are no longer allowed.