Skip to content

Docker: config.json.gz might take precedence over config.json #16837

Description

@Grenadingue

Description

While using docker image, config.json.gz takes precedence over config.json if the web browser accepts gzip encoding. Web browsers accepting gzipped content is very common, so setting a custom configuration has no effect in practice.

Steps to reproduce

  • Launch a container with a custom config attached:
docker run --rm --volume /my/custom/config.json:/app/config.json:ro --publish 127.0.0.1:4242:80 --name test_container vectorim/element-web:latest
  • Request the config file with curl, without explicitly accepting gzip encoding
    • => this should retrieve the custom config.json
curl --verbose http://127.0.0.1:4242/config.json
*   Trying 127.0.0.1:4242...
* Connected to 127.0.0.1 (127.0.0.1) port 4242 (#0)
> GET /config.json HTTP/1.1
> Host: 127.0.0.1:4242
> User-Agent: curl/7.75.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.19.8
< Date: Wed, 31 Mar 2021 22:07:07 GMT
< Content-Type: application/json
< Content-Length: 1785
< Last-Modified: Wed, 31 Mar 2021 21:04:17 GMT
< Connection: keep-alive
< ETag: "6064e3d1-6f9"
< Accept-Ranges: bytes
< 
{
    "default_server_config": {
        "m.homeserver": {
            "base_url": "https://matrix.custom.domain.com",
            "server_name": "matrix.custom.domain.com"
        },
        "m.identity_server": {
            "base_url": "https://vector.im"
        }
    },
...
}
* Connection #0 to host 127.0.0.1 left intact
  • Request the config file with curl, and explicitly accept gzip encoding
curl --verbose --compressed http://127.0.0.1:4242/config.json
*   Trying 127.0.0.1:4242...
* Connected to 127.0.0.1 (127.0.0.1) port 4242 (#0)
> GET /config.json HTTP/1.1
> Host: 127.0.0.1:4242
> User-Agent: curl/7.75.0
> Accept: */*
> Accept-Encoding: deflate, gzip, zstd
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.19.8
< Date: Wed, 31 Mar 2021 22:06:52 GMT
< Content-Type: application/json
< Content-Length: 561
< Last-Modified: Mon, 29 Mar 2021 13:29:28 GMT
< Connection: keep-alive
< ETag: "6061d638-231"
< Content-Encoding: gzip
< 
{
    "default_server_config": {
        "m.homeserver": {
            "base_url": "https://matrix-client.matrix.org",
            "server_name": "matrix.org"
        },
        "m.identity_server": {
            "base_url": "https://vector.im"
        }
    },
...
}
* Connection #0 to host 127.0.0.1 left intact
  • Delete config.json.gz inside the container, then request again the config file via curl with explicit gzip encoding acceptance
    • => this should retrieve the custom config.json :
docker exec test_container /bin/rm -v /app/config.json.gz
curl --verbose --compressed http://127.0.0.1:4242/config.json
*   Trying 127.0.0.1:4242...
* Connected to 127.0.0.1 (127.0.0.1) port 4242 (#0)
> GET /config.json HTTP/1.1
> Host: 127.0.0.1:4242
> User-Agent: curl/7.75.0
> Accept: */*
> Accept-Encoding: deflate, gzip, zstd
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.19.8
< Date: Wed, 31 Mar 2021 22:58:14 GMT
< Content-Type: application/json
< Content-Length: 1785
< Last-Modified: Wed, 31 Mar 2021 21:04:17 GMT
< Connection: keep-alive
< ETag: "6064e3d1-6f9"
< Accept-Ranges: bytes
< 
{
    "default_server_config": {
        "m.homeserver": {
            "base_url": "https://matrix.custom.domain.com",
            "server_name": "matrix.custom.domain.com"
        },
        "m.identity_server": {
            "base_url": "https://vector.im"
        }
    },
...
}
* Connection #0 to host 127.0.0.1 left intact

I would have expected /my/custom/config.json to be retrieved in all the above scenarios.

Logs being sent: no

Version information

  • Platform: web (in-browser)

For the web app:

  • Browser: Firefox 86.0, curl 7.75.0
  • OS: Arch Linux
  • URL: private server, ac15f2755c2c-react-ac15f2755c2c-js-ac15f2755c2c
  • Docker image ID: f46a80d0d949
  • Docker image digest: sha256:fbfdf6c82a32884b1266dbd7fc345be1dcd65240f4b230c10113899baf44b7d4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions