Is it necessary to install nginx in front of docker?

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?

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. Included is a ready-made nginx server block file.

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…


Ah-ha! That I did not know. Thank you for clarifying. I might have comprehended the Advanced Troubleshooting with Docker thread incorrectly then.

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?