server { server_name chat.mydomain.com; # Port 8443 goes to external connection (internet) listen 8443 ssl; # Port 443 is used for internal connections (home) listen 443 ssl; http2 on; access_log /var/log/nginx/chat.mydomain.com_access_log main; error_log /var/log/nginx/chat.mydomain.com_error_log info; location / { # this is to provide a web client, see the ElementWeb page... root /data/daemons/conduwuit/element-web; } location ~ ^(/_matrix|/client) { # The $request_uri is MANDATORY to avoid URI being modifyed by NGINX proxy_pass http://127.0.0.1:6167$request_uri; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD'; proxy_read_timeout 10m; proxy_http_version 1.1; } # This is needed for federation location /.well-known/matrix/server { default_type application/json; add_header Access-Control-Allow-Origin *; return 200 '{"m.server": "chat.mydomain.com:443"}'; } # Enable snail sync for Element X and client access info in general location /.well-known/matrix/client { default_type application/json; add_header Access-Control-Allow-Origin *; return 200 '{"m.homeserver": {"base_url": "https://chat.mydomain.com"},"org.mydomain.msc3575.proxy": {"url": "https://chat.mydomain.com"}}'; } include com.mydomain/certbot.conf; }