server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ =404; } location = /.well-known/matrix/server { default_type application/json; add_header Access-Control-Allow-Origin "*" always; try_files /.well-known/matrix/server.json =404; } location = /.well-known/matrix/server.json { default_type application/json; add_header Access-Control-Allow-Origin "*" always; try_files $uri =404; } location = /.well-known/matrix/client { default_type application/json; add_header Access-Control-Allow-Origin "*" always; add_header Access-Control-Allow-Methods "GET, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type" always; if ($request_method = OPTIONS) { return 204; } try_files /.well-known/matrix/client.json =404; } location = /.well-known/matrix/client.json { default_type application/json; add_header Access-Control-Allow-Origin "*" always; add_header Access-Control-Allow-Methods "GET, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type" always; if ($request_method = OPTIONS) { return 204; } try_files $uri =404; } location ~* \.(?:css|js|ico|png|jpg|jpeg|gif|webp|svg)$ { expires 7d; add_header Cache-Control "public, max-age=604800" always; try_files $uri =404; } }