If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX proxy in front of the Docker container.

If you have not already, please read the Advanced Troubleshooting with Docker guide, as it covers the basics on the separation between host and container.

This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working.

Install nginx outside the container

First, make sure the container is not running:

cd /var/discourse
./launcher stop app

Then install nginx from its PPA (Ubuntu ships by default a very old version, 1.4.0):

sudo add-apt-repository ppa:nginx/stable -y
sudo apt-get update && sudo apt-get install nginx

Change the container definition

This is where we change how Discourse actually gets set up. We don’t want the container listening on ports - instead, we’ll tell it to listen on a special file.

Change your /var/discourse/containers/app.yml to look like this:

# base templates used; can cut down to include less functionality per container templates:
  - "templates/cron.template.yml"
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  # - "templates/web.ssl.template.yml" # uncomment if using HTTPS
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"  # 

Create an NGINX ‘site’ for the outer nginx

For an HTTP site, put this in /etc/nginx/conf.d/discourse.conf, making sure to change the server_name:

server {
        listen 80; listen [::]:80;
        server_name forum.example.com;  # 

For an HTTPS site, make /etc/nginx/conf.d/discourse.conf look like this:

server {
    listen 80; listen [::]:80;
    server_name forum.example.com;  # 

Make sure that the default site is either disabled or has the correct server_name set.

Then, in a shell:

# Make sure that Discourse isn't running
/var/discourse/launcher stop app || true

# test configuration
sudo nginx -t
# Important: If nginx -t comes back with an error, correct the config before reloading!
sudo service nginx reload

# Rebuild the container to apply changes
/var/discourse/launcher rebuild app

Create your other sites

You’re done with the Discourse section!

Make other NGINX “sites”, then link and enable them, as in the last step above.

Source: https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247