Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Synapse should be able to serve a .well-known/matrix/server file #8308

Closed
maquis196 opened this issue Sep 13, 2020 · 11 comments · Fixed by #11211
Closed

Synapse should be able to serve a .well-known/matrix/server file #8308

maquis196 opened this issue Sep 13, 2020 · 11 comments · Fixed by #11211
Assignees
Labels
good first issue Good for newcomers P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution

Comments

@maquis196
Copy link
Contributor

maquis196 commented Sep 13, 2020

I'd like to be able to serve .well-known files directly from the container:

So usually this isn't a problem for most, if you have a classic reverse proxy setup, its super easy to set up one way or another, if youre like me trying to set up traefik, it becomes more complicated. Its possible to setup a seperate nginx instance to catch such requests but personally I'd like to be able to provide either a file to be mounted or variable to be passed into the container that would serve these files.

One workaround for this is to mount a file directly into the static directory and have a redirect on that file.

@erikjohnston
Copy link
Member

It seems we already respond to /.welll-known/matrix/client requests in Synpase (if you set the public_baseurl config). We should document this.

Do you have a use case for also hosting a /.well-known/matrix/server entry?

@erikjohnston erikjohnston added A-Docs things relating to the documentation Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p3 (Deprecated Label) labels Sep 14, 2020
@maquis196
Copy link
Contributor Author

maquis196 commented Sep 14, 2020

My use case is my current setup, having traefik as an edge router is a fairly simple setup involving labels (if a regular docker setup), my only issue is that traefik doesnt seem to provide a way of providing "virtual locations" like nginx does, so if i want to host the well-known/matrix/server, I need to either spin up a separate nginx host to provide one file (which is the solution ive chosen in the interim) so all requests to https://homeserver/.well-known/matrix/server get routed to nginx which isnt great.

If synapse inside docker could provide this itself via static assets that i could easily say mount directly or provided via synapse with say, an environmental value passed to docker, it would make my life easier. Its potentially a pretty niche use case so wanted to see what everyone thought or if there was a way of doing this easily that i haven't considered?

@maquis196
Copy link
Contributor Author

although also, are we able to use SRV records still? not sure ive seen it working for me even though the dns record looks correct

@erikjohnston erikjohnston added z-feature (Deprecated Label) and removed A-Docs things relating to the documentation labels Sep 15, 2020
@erikjohnston
Copy link
Member

OK, sounds like you do also want to host /.well-known/matrix/server. That shouldn't be hard to add alongside the current host /.well-known/matrix/server.

Though having said that, the /.well-known/matrix/server is really only used to route federation traffic elsewhere. If you're already receiving federation traffic into the container then you don't need to route the traffic anywhere else?

although also, are we able to use SRV records still? not sure ive seen it working for me even though the dns record looks correct

SRV records will work. If you haven't seen https://federationtester.matrix.org/ then that can help you debug any issues.

@maquis196
Copy link
Contributor Author

problem is if the container is only receiving traffic in via 443, and all the incoming federation requests without the well-known file are hitting 8448 by default? I suppose in theory i could open up traffic from the router to 443 but still feels like a workaround. Opening that traffic up via traefik is also quite upsetting (multiple services on the same endpoint is not its strong suit).

Ok, good to know, seperately I need to figure out why my SRV record isn't working as intended then, I've tried setting one up first but no dice.

That tool is very useful, also raised a bug on there because only having high ciphers enabled breaks that utility as well (or at least breaks fetching the above well-known file).

@33Fraise33
Copy link

I have the exact same use case.

All my traffic is entering with a cname's pointing to my dyndns record. Traffic is then handled by traefik on port 443 which is a reverse proxy for the docker container on 8008. It would be very nice not having to run nginx in front of 8008 and behind traefik.

For now SRV records work to point it to 443 but I would prefer hosting the static file inside the container (possible through an entry in the homeserver.yaml)

Example:

well_known_server_config:
  server: "matrix-federation.matrix.org:443"

@Aricg
Copy link

Aricg commented Mar 17, 2021

Same use case, kubernetes with traffeik to Ingress
I will need to swap out for nginx and cert-manager now
so that I can do some nginx trickery like

	location /.well-known/matrix/server {
		default_type application/json;
		return 200 '{"m.server": "matrix.example.com:443"}';
	}

But i was lost for a while as

.well-known/matrix/client exists so I was banging my head for the option to set .well-known/matrix/server
I guess I could run a new service just for this one line of json, but ew.

@michael-robbins
Copy link

Stumbled across this issue today as well, have a traefik proxy handling the requests to this, similar to the above scenarios.

It would be great if synapse can also host this too.

@reivilibre reivilibre added good first issue Good for newcomers P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. and removed z-feature (Deprecated Label) z-p3 (Deprecated Label) labels Aug 2, 2021
@reivilibre reivilibre changed the title Being able to serve .well-known files via the container. Synapse should be able to serve a .well-known/matrix/server file Aug 2, 2021
@reivilibre
Copy link
Contributor

This seems a reasonable request. I have changed the title to clarify that it's really .well-known/matrix/server that we're interested in serving.

I can see this also being useful for being able to get away from using 8448 as the default federation port (which afaict is more for legacy reasons nowadays), as having this built-in to Synapse could make it easier to configure this.

@Cognitheurge
Copy link

I may be mistaken, but several people mention that they're using a proxy to serve synapse, I'm doing the same and hosting it on a subdomain. As the well-known entry is generated using just the server_name it does not support sub-domains. If it was generated based on public_baseurl, or something similar, this would correct for that, no?

my current setup uses Traefiks regexRedirect to redirect the the well-known address to where synapse serves it. I can probably setup an nginx container to host the right information in the right location. I just want to know if this setting already exists and I'm just missing something

@richvdh
Copy link
Member

richvdh commented Feb 28, 2022

No, synapse doesn't allow you to modify the target of the .well-known file. It seems odd that traefik can serve a 302, but not a 200.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants