/.well-known not working with Cloudflare proxy

I have an issue with the cloudflare website proxy: /.well-known does not seem to work correctly.
I use nginx webserver to serve ./well-known and other static content. Here is the relevant snippet from my nginx.conf:

server {
listen 80; # IPv4
listen [::]:80; # IPv6
listen 443 ssl http2; # IPv4
listen [::]:443 ssl http2; # IPv6
server_name xxx.com;
include snippets/ssl.conf;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 600;

location /.well-known/matrix/server {
	return 200 '{ "m.server": "matrix.xxx.com:443" }';

location /.well-known/matrix/client {
	add_header Access-Control-Allow-Origin '*';
	return 200 '{ "m.homeserver": { "base_url": "https://matrix.xxx.com" } }';

This works perfectly without the Cloudflare proxy. However, as soon as I enable the Cloudflare proxy, the Matrix client is unable to get the information from /.well-known/matrix/server.

Has anyone made similar experiences? Any idea on how to get the configuration working with Proxy enabled?

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.