# How to use REST API service with nginx in front

**URL:** <https://meta.discourse.org/t/how-to-use-rest-api-service-with-nginx-in-front/48900>\
**Category:** Self-hosting\
**Tags:** hosting\
**Created:** [2016年八月19日 22:27 UTC](https://meta.discourse.org/t/how-to-use-rest-api-service-with-nginx-in-front/48900 "2016-08-19T22:27:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Webtrend](https://avatars.discourse-cdn.com/v4/letter/w/43a26b/32.png) [@Webtrend](https://meta.discourse.org/u/Webtrend)\
**Post date:** [2016年八月19日 22:27 UTC](https://meta.discourse.org/t/how-to-use-rest-api-service-with-nginx-in-front/48900/1 "2016-08-19T22:27:21Z")

</div>

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?
