diff --git a/mx-tester.yml b/mx-tester.yml index 12e9e5b8..a249b61a 100644 --- a/mx-tester.yml +++ b/mx-tester.yml @@ -6,7 +6,7 @@ up: # Wait until postgresql is ready - until psql postgres://mjolnir-tester:mjolnir-test@127.0.0.1:8083/mjolnir-test-db -c ""; do echo "Waiting for psql..."; sleep 1s; done # Launch the reverse proxy, listening for connections *only* on the local host. - - docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8081:80 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx + - docker run --rm --network host --name mjolnir-test-reverse-proxy -p 127.0.0.1:8084:8084 -p 127.0.0.1:8085:8085 -p 127.0.0.1:8086:8086 -p 127.0.0.1:8081:8081 -v $MX_TEST_CWD/test/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx - yarn install - npx ts-node src/appservice/cli.ts -r -u "http://host.docker.internal:9000" - cp mjolnir-registration.yaml $MX_TEST_SYNAPSE_DIR/data/ diff --git a/test/nginx.conf b/test/nginx.conf index 23c73c76..9892e443 100644 --- a/test/nginx.conf +++ b/test/nginx.conf @@ -4,29 +4,74 @@ events { http { server { - listen [::]:8081 ipv6only=off; - - location ~ ^/_matrix/client/(r0|v3)/rooms/([^/]*)/report/(.*)$ { - # Abuse reports should be sent to Mjölnir. - # The r0 endpoint is deprecated but still used by many clients. - # As of this writing, the v3 endpoint is the up-to-date version. - - # Add CORS, otherwise a browser will refuse this request. - add_header 'Access-Control-Allow-Origin' '*' always; # Note: '*' is for testing purposes. For your own server, you probably want to tighten this. - add_header 'Access-Control-Allow-Credentials' 'true' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - add_header 'Access-Control-Max-Age' 1728000; # cache preflight value for 20 days - - # Alias the regexps, to ensure that they're not rewritten. - set $room_id $2; - set $event_id $3; - proxy_pass http://127.0.0.1:8082/api/1/report/$room_id/$event_id; + listen [::]:8081 ipv6only=off; + + location ~ ^/_matrix/client/(r0|v3)/rooms/([^/]*)/report/(.*)$ { + # Abuse reports should be sent to Mjölnir. + # The r0 endpoint is deprecated but still used by many clients. + # As of this writing, the v3 endpoint is the up-to-date version. + + # Add CORS, otherwise a browser will refuse this request. + add_header 'Access-Control-Allow-Origin' '*' always; # Note: '*' is for testing purposes. For your own server, you probably want to tighten this. + add_header 'Access-Control-Allow-Credentials' 'true' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; + add_header 'Access-Control-Max-Age' 1728000; # cache preflight value for 20 days + + # Alias the regexps, to ensure that they're not rewritten. + set $room_id $2; + set $event_id $3; + proxy_pass http://127.0.0.1:8082/api/1/report/$room_id/$event_id; + } + # MSC1929 Test in best-case + location /.well-known/matrix/support { + default_type application/json; + return 200 '{ + "contacts": [{ + "matrix_id": "@admin:localhost", + "role": "admin" + }], + "support_page": "http://localhost" + }'; + } + location / { + # Everything else should be sent to Synapse. + proxy_pass http://127.0.0.1:9999; + } + } + server { + listen [::]:8084 ipv6only=off; + + # MSC1929 Test in worst-case + location /.well-known/matrix/support { + default_type application/json; + return 404 '{}'; + } + } + server { + listen [::]:8085 ipv6only=off; + + # MSC1929 Test in supportpage_only-case + location /.well-known/matrix/support { + default_type application/json; + return 200 '{ + "support_page": "http://localhost" + }'; + } } - location / { - # Everything else should be sent to Synapse. - proxy_pass http://127.0.0.1:9999; + server { + listen [::]:8086 ipv6only=off; + + # MSC1929 Test in contacts-case + location /.well-known/matrix/support { + default_type application/json; + return 200 '{ + "contacts": [{ + "matrix_id": "@admin:localhost", + "role": "admin" + }], + }'; } } }