# Is it necessary to install nginx in front of docker?

**URL:** https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450
**Category:** Self-hosting
**Created:** [11 Abril, 2015 14:01 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450 "2015-04-11T14:01:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [11 Abril, 2015 14:01 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450/1 "2015-04-11T14:01:17Z")

</div>

As we know, nginx has installed in discourse docker,

plan 1: If you install discourse on a machine, and expose 80 port external,

plan 2: If you install discourse on a machine, and expose non 80 port external, like port 3333, then install nginx on the same host for reverse proxy to docker,

Which is better and safer?

Is it necessary to install nginx on host?

---

<div class="post-metadata">

### Author: ![purldator](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@purldator](https://meta.discourse.org/u/purldator)
#### Post date: [11 Abril, 2015 14:17 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450/2 "2015-04-11T14:17:46Z")

</div>

You need a web server on the host to serve Discourse in the container, even though nginx is installed in the container too. Nginx is suggested for the host too.

As for your plans, [check out this post I made about this subject](https://meta.discourse.org/t/help-understanding-the-structure-of-using-discourse-static-website/25557/4). Included is a ready-made nginx server block file.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [11 Abril, 2015 15:50 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450/3 "2015-04-11T15:50:39Z")

</div>

It depends on what @doudou wants to do. If the machine is _only_ hosting Discourse, no webserver is required besides the nginx provided by and installed inside the Discourse docker container. In the case that he wants to host other content on the same machine, he will have to run a webserver on the host and reverse-proxy to Discourse, but

1. pretty much any webserver that handles many long-lasting connections well will do; nginx is recommended because it does this by default, but Apache will do as well **if** it is configured properly.

2. the second nginx inside the container is not _strictly_ required. the host webserver can reverse-proxy directly to the Discourse app server (unicorn). However, this is not recommended because the container’s nginx is configured with Discourse in mind and a non-ideal self-made config could impact performance more significantly than running the request through another proxying nginx instance…

---

<div class="post-metadata">

### Author: ![purldator](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@purldator](https://meta.discourse.org/u/purldator)
#### Post date: [11 Abril, 2015 16:21 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450/4 "2015-04-11T16:21:15Z")

</div>

> [@elberet](#):
>
> If the machine is only hosting Discourse, no webserver is required besides the nginx provided by and installed inside the Discourse docker container.

Ah-ha! That I _did not_ know. Thank you for clarifying. I might have comprehended the [Advanced Troubleshooting with Docker](https://meta.discourse.org/t/advanced-troubleshooting-with-docker/15927) thread incorrectly then.

---

<div class="post-metadata">

### Author: ![doudou](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@doudou](https://meta.discourse.org/u/doudou)
#### Post date: [12 Abril, 2015 01:29 UTC](https://meta.discourse.org/t/is-it-necessary-to-install-nginx-in-front-of-docker/27450/5 "2015-04-12T01:29:19Z")

</div>

If we choose plan 2, nginx on the host will allow you add other sites on the same host, but how to write conf.d/discourse.conf to reverse proxy discourse in the docker?

Should the **conf.d/discourse.conf on the host** be the same as **conf.d/discourse.conf in the docker**?

Any example?
