Discourse not working through separate nginx docker


#1

I’m trying to install discourse on my server with Ubuntu Server 16.04, where I’m already running a docker compose file with nginx. All containers in my docker file are on a separate network. I followed this guide mostly. I succesfully rebuild the app and setup nginx with the following setup:

server {
    listen 80; listen [::]:80;
    server_name talk.webserver.nl;

    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name talk.webserver.nl;

    ssl 					on;
	include     			/etc/nginx/confs/nginx-ssl.conf;
	ssl_session_tickets 	off;

    location / {
        proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
    }
}

With this I cannot access talk.webserver.nl. I noticed it’s trying to call /var/discourse/shared/standalone/nginx.http.sock so I decided to add that to my nginx volumes. That didn’t work either, so it’s probably not necessary to have this in my volumes at all? I have no idea how the unix reference works and I can’t find anything on it.

When I shell access nginx I can ping to all my other containers but I’m not able to ping to the discourse container. Not sure if that has anything to do with it. What can I do to debug this?


Running other websites on the same machine as Discourse
Running other websites on the same machine as Discourse
(Kane York) #2

The way the volumes work is that HOST /var/discourse/shared/NAME is mapped to CONTAINER /shared. They’re already set up in the default app.yml.

The Discourse container /shared is mapped to the host /var/discourse/shared/NAME. You’ll need to make a new volume for your nginx container, maybe call it /discourse_shared, mapping to the same location.

Then your directive becomes:

proxy_pass http://unix:/discourse_shared/nginx.http.sock:;

#3

I don’t quite understand how I would manage to do this. My /shared folder only contains the folder standalone.

The nginx part of my docker compose file looks like this:

  nginx:
    image: sickp/alpine-nginx:1.13.0-r1
    container_name: nginx
    ports:
      - "443:443"
      - "80:80"
    networks:
      - plexnet
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - ${CONFIG_FOLDER}/nginx/nginx.conf:/etc/nginx/nginx.conf
      - ${CONFIG_FOLDER}/nginx/www:/etc/nginx/www
      # Configs
      - ${CONFIG_FOLDER}/nginx/confs:/etc/nginx/confs:ro
      # SSL
      - ${CONFIG_FOLDER}/nginx/dhparam.pem:/etc/nginx/dhparam.pem:ro
      - /etc/letsencrypt:/etc/letsencrypt:ro
      # Discourse websocket
      - /var/discourse/:/var/discourse/

With this /var/discourse/ becomes fully accessible in my nginx container through /var/discourse/shared/standalone/nginx.http.sock. Isn’t this what you mean?


#4

I found the solution. I had to add the following to the .yml file:

docker_args: "--network apps_plexnet"

networks:
  apps_plexnet:
    external: true

After that I rebuilt it. Now they can see eachother and it all works.