Exactly, it’s nginx trickery. See: https://gitlab.com/soapbox-pub/soapbox/-/blob/develop/installation/mastodon.conf
Sidenote, we also offer a Docker image which does this: registry.gitlab.com/soapbox-pub/soapbox
https://gitlab.com/soapbox-pub/soapbox/-/blob/develop/Dockerfile
I have not actually tested that federation works with this setup, but in theory you should be able to direct traffic to this nginx container and run it like docker run -e BACKEND_URL=http://backend:3000 registry.gitlab.com/soapbox-pub/soapbox
Assuming the Mastodon container is on the same network.