How to use REST API service with nginx in front

I have discourse installed in docker container with nginx in front acting as a load balancer. I would like to access REST API which is served from port 3000 per the API documentation.

How do I expose port 3000 on the container. Is this correct?

  • “127.0.0.1:3000:3333”

Also how do I configure the nginx running in front? Currently to route the port 80 traffic, my upstream block looks like this

upstream discourse {
 server 127.0.0.1:8080;
}

I tried this but my nginx in front is not routing the traffic to the container and I get 404 error when I make API calls.

upstream discourse {
     server 127.0.0.1:8080;
     server 127.0.0.1:3333;
    }
server {
    listen 3333;
}

What am I doing wrong?