Matrix Synapse behind HAProxy on pfSense
-
I serve my well-know from the matrix server. I just published the whole domain on port 443.
Anyway you error suggest that there is no 'matrix-well-known-server' and 'matrix-well-known-client'.
ACL rule and indeed you call your rules 'matrix-well-known-client-path' and 'matrix-well-known-server-path' and under actions you use the names without the -path suffix.Also the actions are redundant and is where the error is coming from.
Use either actions and Access Control List where you set the matrix.ibi.. stuff.
Or remove the actions and use advanced pass thru option.I would suggest remove the advanced pass thru on the frontend entirely.
Just add 2 more ACLs matching the actions you already added
Don't forget to add -path at the end of you actions Condition acl names.
-
I'm sorry I didn't respond earlier. I had to replace my Synology Reverse Proxy in the background. I implemented your settings as follows, but unfortunately, without success. I must be doing something wrong; could you please check my configuration?
In Matrix Federation, I'm getting an error.Frontend:
Element-Matrix Frontend
Shared Frontend
Matrix-Synapse
Well-Kown Config
Backend
Well-Kown Config
-
Hi,
Looks fine to me. Except the frondend IPsI don't know you setup with pfsense but mine is used as main router connected to a WAN interface.
Thats where the frontend has to listen.
Yours displaying a private 192.168... address.You should be able to navigate to your site. matrix.[yourdomain].de/.well-known/matrix/server
And get the json response.Thats only happening if you make your HAProxy listening on you WAN IP.
Also your DNS should point to you WAN IP.These are my frontends
One for Federation.
One for the web stuff. Which includes the /.well-known stuff and all clients like element and cinny I let the server handle that for me.This are my backends
I don't use the advanced configuration.
I also added two allow rules to the WAN interface on the firewall for port 443 and 8448 as I mentioned in an earlier post.
Not sure whats the problem is withs yours. I could be the wan configuration or the backend configuration.
Try debugging it with the hosts file. And add your domain to it with the pfsense local IP/matrix server IP and see if it works locally before testing it over the internet.
/etc/hosts
192.168.1.1 matrix.yourdomain.com
Then your computer will use your local ip for your domain.
BTW I use this to manage my server.
https://github.com/spantaleev/matrix-docker-ansible-deploySince matrix has a lot of moving parts its nice to have a consistent installation.
Hope you get it figured out.
-
Damn it, i didnt get it run. I dont know where my error is.
I dont wont to give up. Can you further support me?
Lets start from beginning. My synapse config shows this configuration:
server_name: "domain.de" public_baseurl: "https://matrix.domain.de" serve_server_wellknown: true
DNS Settings
Host A Entry
domain.de -> IPv4 Adresse
Host A Entry
matrix.domain.de -> IPv4 AdresseFront End Matrix
Listen addresse (Shared Frontend)
CARP WAN 1 Port 443 SSL Offloading
CARP WAN 2 Port 443SSL Offloading
Access Control lists
matrix Host Matches matrix.domain.de
Actions
use backend matrix matrix-synapse
Use "forwardfor" option.Backend
Server list
192.168.8.8 8448Front End Federation
Listen addresse
CARP WAN 1 Port 443 SSL Offloading
CARP WAN 1 Port 8448
Access Control lists
Actions
Use "forwardfor" option.
Server CertficateBackend matrix-well-known-client
Advanced Settings
http-after-response set-header Access-Control-Allow-Origin "*"
http-after-response set-header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
http-after-response set-header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"
http-request return status 200 content-type application/json string '{"m.homeserver":{"base_url":"https://matrix.domain.de"}}'Backend matrix-well-known-server
Advanced Settings
http-after-response set-header Access-Control-Allow-Origin "*"
http-after-response set-header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
http-after-response set-header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"
http-request return status 200 content-type application/json string '{"m.server":"matrix.domain.de:443"}'Federation Tester failed
-
I mean, a lot of this is going to depend on your matrix config as well.
It looks mostly fine to me, but firstly:
serve_server_wellknown: trueShould not be set in your homeserver.yaml becuase you are serving the well-known from the reverse proxy. This setting makes it available to serve from your matrix host, which is not needed for you. This isn't your issue though.
I see your back end is forwarding to 8448. That requires TLS certs on your matrix server and your homeserver.yaml configured to use them. If that's the case, then I think your well-known/matrix/server should be set to port 8448 and not 443.
I would recommend configuring your matrix listener to listen on 8008 instead and your backend configured to go to 8008 without TLS. With this you dont need a frontend for 8448 and you can leave your well-known/matrix/server port at 443.
-
First, thank you very much for your support.
Done
It looks mostly fine to me, but firstly: serve_server_wellknown: true
Done
I see your back end is forwarding to 8448. That requires TLS certs on your matrix server and your homeserver.yaml configured to use them. If that's the case, then I think your well-known/matrix/server should be set to port 8448 and not 443.
Done
I would recommend configuring your matrix listener to listen on 8008 instead and your backend configured to go to 8008 without TLS. With this you dont need a frontend for 8448 and you can leave your well-known/matrix/server port at 443.
The Federation Matrix Error Code
{ "WellKnownResult": { "m.server": "", "result": "Get \"https://domain.de/.well-known/matrix/server\": x509: certificate has expired or is not yet valid: current time 2023-10-05T08:24:35Z is after 2023-06-14T15:01:22Z", "CacheExpiresAt": 0 }, "DNSResult": { "SRVSkipped": false, "SRVCName": "", "SRVRecords": null, "SRVError": { "Message": "lookup _matrix._tcp.domain.de on 8.8.8.8:53: no such host" }, "Hosts": { "domain.de": { "CName": "domain.de.", "Addrs": [ "2a03:4000:61:5c1f::19:967", "87.122.55.127" ], "Error": null } }, "Addrs": [ "[2a03:4000:61:5c1f::19:967]:8448", "87.122.55.127:8448" ] }, "ConnectionReports": {}, "ConnectionErrors": { "87.122.55.127:8448": { "Message": "Get \"https://87.122.55.127:8448/_matrix/key/v2/server\": EOF" }, "[2a03:4000:61:5c1f::19:967]:8448": { "Message": "Get \"https://[2a03:4000:61:5c1f::19:967]:8448/_matrix/key/v2/server\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)" } }, "Version": { "error": "Get \"matrix://domain.de/_matrix/federation/v1/version\": EOF" }, "FederationOK": false }
-
@sub2010
The error is telling you exactly what's wrong. You have an expired cert that expired on June 14th. Check the cert on your haproxy front end and the one on your matrix host if you have one. -
@OCT0PUSCRIME
I didnt get it. AGAIN ;-).First i have a wildcard Certificate, this ist for matrix.domain.de
But my matrix Server runs on servername domain.deHow i can configure the cert for any the domain.de?
This is my frontend configuration
-
Is this SRV Entry correct?
Same Error as well.
{ "WellKnownResult": { "m.server": "", "result": "Get \"https://domain.de/.well-known/matrix/server\": x509: certificate has expired or is not yet valid: current time 2023-10-05T15:37:02Z is after 2023-06-14T15:01:22Z", "CacheExpiresAt": 0 }, "DNSResult": { "SRVSkipped": false, "SRVCName": "_matrix._tcp.domain.de.", "SRVRecords": [ { "Target": "matrix.domain.de.", "Port": 443, "Priority": 1, "Weight": 1 } ], "SRVError": null, "Hosts": { "matrix.domain.de.": { "CName": "matrix.domain.de.", "Addrs": [ "87.122.55.127" ], "Error": null } }, "Addrs": [ "87.122.55.127:443" ] }, "ConnectionReports": {}, "ConnectionErrors": { "87.122.55.127:443": { "Message": "Non-200 response 503 from remote server" } }, "Version": { "error": "Get \"matrix://domain.de/_matrix/federation/v1/version\": x509: certificate is valid for *.domain.de, not domain.de" }, "FederationOK": false }
How can i change the certificate?
-
@sub2010
I use the same config. domain.tld and matrix.domain.tld. I'm not sure about your srv record, I dont use one.For my certificate I use 1 certificate. In acme you can specify multiple domains for one certificate. Mine includes. *.domain.tld and domain.tld
Get a cert like that, put it on your haproxy frontend and also put it on your matrix host and point your homeserver.yaml to it and restart matrix. The error is still saying your cert is expired, so I am assuming the cert you have on your matrix host that your homeserver.yaml is pointing to is expired.