Reverse Proxy Between Docker Containers via Caddy Docker Container

Unfortunately I don’t have control over Firebase Emulator so I can’t change the protocol, I wish they just use the // for the paths so we wouldn’t deal with these headaches.

Now, this client is Firebase itself and it’s also a container. If the Firebase Emulator was calling directly from its side there won’t be problem because all those ports are already exposed. It seems frontend making this call which passes through my host machine. It fails because I have nothing that listening this ports actually. I think I need to map the port through docker’s port mapping to redirect to the container itself. Will try and let you know.

Yep, you’ve currently got those ports under the expose: header in your docker-compose.yaml. You’ll need to transfer the ones you want to expose directly to a ports: header, and Docker will punch out those ports to the host and its firewall.

Yeap it works now after I added this to my docker-compose.yml file.

    ports:
      - 127.0.0.1:4000:4000 # Emulator Hub
      - 127.0.0.1:4400:4400 # Emulator Hub
      - 127.0.0.1:9393:9393 # Emulator UI
      - 127.0.0.1:9099:9099 # Firebase Auth
      - 127.0.0.1:5001:5001 # Firebase Functions
      - 127.0.0.1:8080:8080 # Firebase Firestore
      - 127.0.0.1:8085:8085 # Firebase Pub/Pub
      - 127.0.0.1:9199:9199 # Firebase Storage

It seems no point after all it works partially use http. Didn’t need to go to all trouble to make it happen, my purpose was creating a totally isolated local development environment just using docker containers in a secure way.

Now, if I want to make it secure, I have to run caddy on my host.

Anyway, this is only for local development, so this will do the job.

Thanks a lot @Whitestrake for the great points you made it!

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.