# \[solved\] Docker Compose Mattermost with nginx Proxy dont work

**URL:** <https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081>\
**Category:** Troubleshooting\
**Created:** [April 14, 2019, 1:04pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081 "2019-04-14T13:04:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 14, 2019, 1:04pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/1 "2019-04-14T13:04:32Z")

</div>

#### Summary

Mattermost docker image with nginx proxy dont work

#### Expected behavior

i install mattermost with docker-compose with this config =

version: “2”

services:

db:  
build: db  
restart: unless-stopped  
volumes:  
- ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data  
- /etc/localtime:/etc/localtime:ro  
environment:  
- POSTGRES\_USER=user  
- POSTGRES\_PASSWORD=pw  
- POSTGRES\_DB=mattermost  
# uncomment the following to enable backup  
# - AWS\_ACCESS\_KEY\_ID=XXXX  
# - AWS\_SECRET\_ACCESS\_KEY=XXXX  
# - WALE\_S3\_PREFIX=s3://BUCKET\_NAME/PATH  
# - AWS\_REGION=us-east-1

app:  
build:  
context: app  
# comment out 2 following lines for team edition  
# args:  
# - edition=team  
restart: unless-stopped  
volumes:  
- ./volumes/app/mattermost/config:/mattermost/config:rw  
- ./volumes/app/mattermost/data:/mattermost/data:rw  
- ./volumes/app/mattermost/logs:/mattermost/logs:rw  
- /etc/localtime:/etc/localtime:ro  
environment:  
# set same as db credentials and dbname  
- MM\_USERNAME=user  
- MM\_PASSWORD=pw  
- MM\_DBNAME=mattermost  
# in case your config is not in default location  
#- MM\_CONFIG=/mattermost/config/config.json  
ports:  
- “8000:443”  
links:  
- db:db

i bring it up wit docker-compuse up -d

my nginx proxy config file =

upstream mattermost {  
server 127.0.0.1:8000;  
}

proxy\_cache\_path /var/cache/nginx levels=1:2 keys\_zone=mattermost\_cache:10m max\_size=3g inactive=120m use\_temp\_path=off;

server {  
server\_name mydomain;

location ~ /api/v[0-9]+/(users/)?websocket$ {  
proxy\_set\_header Upgrade $http\_upgrade;  
proxy\_set\_header Connection “upgrade”;  
client\_max\_body\_size 50M;  
proxy\_set\_header Host $http\_host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;  
proxy\_set\_header X-Frame-Options SAMEORIGIN;  
proxy\_buffers 256 16k;  
proxy\_buffer\_size 16k;  
proxy\_read\_timeout 600s;  
proxy\_pass [http://mattermost](http://mattermost);  
}

location / {  
client\_max\_body\_size 50M;  
proxy\_set\_header Connection “”;  
proxy\_set\_header Host $http\_host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;  
proxy\_set\_header X-Frame-Options SAMEORIGIN;  
proxy\_buffers 256 16k;  
proxy\_buffer\_size 16k;  
proxy\_read\_timeout 600s;  
proxy\_cache mattermost\_cache;  
proxy\_cache\_revalidate on;  
proxy\_cache\_min\_uses 2;  
proxy\_cache\_use\_stale timeout;  
proxy\_cache\_lock on;  
proxy\_pass [http://mattermost](http://mattermost);  
}

when i go to the site its come nginx bad gateway. i read many instruction but i dont know where is my failure.

in the nginx log file =

connect() failed (111: Connection refused) while connecting to upstream, client:

Thanks Felix

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [April 15, 2019, 1:42pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/2 "2019-04-15T13:42:00Z")

</div>

Hi @Felix,

Were you following the “How do I setup an NGINX proxy with the Mattermost Docker installation?” section of this doc [https://docs.mattermost.com/install/config-proxy-nginx.html](https://docs.mattermost.com/install/config-proxy-nginx.html)?

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 15, 2019, 2:05pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/3 "2019-04-15T14:05:16Z")

</div>

first thanks for you reply.

i see the link and i read the link, but is the doc real or outdatet.

i read thats mattermost 5… the port is now 8000 and not 8065. The docker app container say also 8000. So now i ám confused.  
Also when i expose ports in the config file, always is come thats blocked not ended.

To my understand.

Port is 8065?  
I bind my nginx proxy to 127.0.0.1:8065?

sry too much frustration and i think it is my fault 🙂

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [April 15, 2019, 2:28pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/4 "2019-04-15T14:28:34Z")

</div>

@pichouk Do you know more about this issue?

---

<div class="post-metadata">

**Author:** ![pichouk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/pichouk/32/1347_2.png) [@pichouk](https://forum.mattermost.com/u/pichouk)\
**Post date:** [April 15, 2019, 4:30pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/5 "2019-04-15T16:30:47Z")

</div>

Hi @Felix,

Why did you bind your `app` container port `8000` to `443` ?

```auto
ports:
- “8000:443”

```

I think you should use port `8000` instead. Mattermost service is not listening on port `443` if you use the Docker image.

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 15, 2019, 6:39pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/6 "2019-04-15T18:39:14Z")

</div>

Hi pichouk,

that expose was from one test. I set it now again from scratch but also , ist has always error 500.

i post you my settings:

## ubuntu , nginx, docker

docker-compose.xml

version: “2”

services:

db:  
build: db  
read\_only: true  
restart: unless-stopped  
volumes:  
- ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data  
- /etc/localtime:/etc/localtime:ro  
environment:  
- POSTGRES\_USER=mmuser  
- POSTGRES\_PASSWORD=mmuser\_password  
- POSTGRES\_DB=mattermost  
# uncomment the following to enable backup  
# - AWS\_ACCESS\_KEY\_ID=XXXX  
# - AWS\_SECRET\_ACCESS\_KEY=XXXX  
# - WALE\_S3\_PREFIX=s3://BUCKET\_NAME/PATH  
# - AWS\_REGION=us-east-1

app:  
build:  
context: app  
# uncomment following lines for team edition or change UID/GID  
# args:  
# - edition=team  
# - PUID=1000  
# - PGID=1000  
restart: unless-stopped  
volumes:  
- ./volumes/app/mattermost/config:/mattermost/config:rw  
- ./volumes/app/mattermost/data:/mattermost/data:rw  
- ./volumes/app/mattermost/logs:/mattermost/logs:rw  
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw  
- ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw  
- /etc/localtime:/etc/localtime:ro  
environment:  
# set same as db credentials and dbname  
- MM\_USERNAME=mmuser  
- MM\_PASSWORD=mmuser\_password  
- MM\_DBNAME=mattermost  
# in case your config is not in default location  
#- MM\_CONFIG=/mattermost/config/config.json

* * *

nginx site config

upstream mattermost {  
server 127.0.0.1:8000;  
}

proxy\_cache\_path /var/cache/nginx levels=1:2 keys\_zone=mattermost\_cache:10m max\_size=3g inactive=120m use\_temp\_path=off;

server {  
server\_name xxx;

location ~ /api/v[0-9]+/(users/)?websocket$ {  
proxy\_set\_header Upgrade $http\_upgrade;  
proxy\_set\_header Connection “upgrade”;  
client\_max\_body\_size 50M;  
proxy\_set\_header Host $http\_host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;  
proxy\_set\_header X-Frame-Options SAMEORIGIN;  
proxy\_buffers 256 16k;  
proxy\_buffer\_size 16k;  
proxy\_read\_timeout 600s;  
proxy\_pass [http://mattermost](http://mattermost);  
}

location / {  
client\_max\_body\_size 50M;  
proxy\_set\_header Connection “”;  
proxy\_set\_header Host $http\_host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header X-Forwarded-Proto $scheme;  
proxy\_set\_header X-Frame-Options SAMEORIGIN;  
proxy\_buffers 256 16k;  
proxy\_buffer\_size 16k;  
proxy\_read\_timeout 600s;  
proxy\_cache mattermost\_cache;  
proxy\_cache\_revalidate on;  
proxy\_cache\_min\_uses 2;  
proxy\_cache\_use\_stale timeout;  
proxy\_cache\_lock on;  
proxy\_pass [http://mattermost](http://mattermost);  
}

* * *

docker ps:

## mattermost-docker\_db 5432/tcp mattermost-docker\_app 8000/tcp

i have delete the web config in docker-compose, because nginx proxy.

in my nginx log file:

failed (111: Connection refused) while connecting to upstream,

What did I miss? Thank you very much for your time and help. Felix

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 15, 2019, 6:43pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/7 "2019-04-15T18:43:29Z")

</div>

My debt and excuse me for taking up your time. I set in the nginx the docker ip from mattermost\_app and the the upstream is correct.

Thanks again for trying to help me! Felix

---

<div class="post-metadata">

**Author:** ![pichouk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/pichouk/32/1347_2.png) [@pichouk](https://forum.mattermost.com/u/pichouk)\
**Post date:** [April 15, 2019, 8:17pm UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/8 "2019-04-15T20:17:32Z")

</div>

You should keep this part I think :

```auto
ports:
  - “8000:8000”

```

I guess you can have something working with this `docker-compose.yml`

```auto
version: “2”
services:
  db:
    build: db
    read_only: true
    restart: unless-stopped
    volumes:
      - ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data
      - /etc/localtime:/etc/localtime:ro
    environment:
      - POSTGRES_USER=mmuser
      - POSTGRES_PASSWORD=mmuser_password
      - POSTGRES_DB=mattermost

  app:
    build:
      context: app
    restart: unless-stopped
    volumes:
      - ./volumes/app/mattermost/config:/mattermost/config:rw
      - ./volumes/app/mattermost/data:/mattermost/data:rw
      - ./volumes/app/mattermost/logs:/mattermost/logs:rw
      - ./volumes/app/mattermost/plugins:/mattermost/plugins:rw
      - ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MM_USERNAME=mmuser
      - MM_PASSWORD=mmuser_password
      - MM_DBNAME=mattermost
    ports:
      - “8000:8000”

```

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 16, 2019, 6:13am UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/9 "2019-04-16T06:13:24Z")

</div>

Thanks, it works now when i bind the nginx proxy to the docker ip from the mattermost app with port 8000.

But i have one question, when i uncomment the arg line with the edition or i wrote the port line, docker-compose write a failure:

ERROR: yaml.parser.ParserError: while parsing a block mapping  
in “./docker-compose.yml”, line 24, column 7  
expected , but found ‘’  
in “./docker-compose.yml”, line 26, column 8

args:  
- edition=team

or when i set the ports as in your example.

---

<div class="post-metadata">

**Author:** ![pichouk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/pichouk/32/1347_2.png) [@pichouk](https://forum.mattermost.com/u/pichouk)\
**Post date:** [April 16, 2019, 9:09am UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/10 "2019-04-16T09:09:11Z")

</div>

I think it’s just because I made a bad copy paste. I wrote `”` instead of `"`.

If you write

```auto
ports:
  - "80:80"

```

I think it will works better 🙂

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 16, 2019, 9:14am UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/11 "2019-04-16T09:14:39Z")

</div>

I’ve still got the wrong one.

my docker.yml

* * *

version: “2”

services:

db:  
build: db  
read\_only: true  
restart: unless-stopped  
volumes:  
- ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data  
- /etc/localtime:/etc/localtime:ro  
environment:  
- POSTGRES\_USER=xxx  
- POSTGRES\_PASSWORD=xxx  
- POSTGRES\_DB=xxx  
# uncomment the following to enable backup  
# - AWS\_ACCESS\_KEY\_ID=XXXX  
# - AWS\_SECRET\_ACCESS\_KEY=XXXX  
# - WALE\_S3\_PREFIX=s3://BUCKET\_NAME/PATH  
# - AWS\_REGION=us-east-1

app:  
build:  
context: app  
# uncomment following lines for team edition or change UID/GID  
args:  
- edition=team  
# - PUID=1000  
# - PGID=1000  
restart: unless-stopped  
volumes:  
- ./volumes/app/mattermost/config:/mattermost/config:rw  
- ./volumes/app/mattermost/data:/mattermost/data:rw  
- ./volumes/app/mattermost/logs:/mattermost/logs:rw  
- ./volumes/app/mattermost/plugins:/mattermost/plugins:rw  
- ./volumes/app/mattermost/client-plugins:/mattermost/client/plugins:rw  
- /etc/localtime:/etc/localtime:ro  
environment:  
# set same as db credentials and dbname  
- MM\_USERNAME=xxx  
- MM\_PASSWORD=xxx  
- MM\_DBNAME=xxx  
ports:  
- “8000:8000”  
# in case your config is not in default location  
#- MM\_CONFIG=/mattermost/config/config.json

I become the same issues by the edition and the port parameter:

expected , but found ‘?’

---

<div class="post-metadata">

**Author:** ![Felix](https://avatars.discourse-cdn.com/v4/letter/f/aeb1de/32.png) [@Felix](https://forum.mattermost.com/u/Felix)\
**Post date:** [April 16, 2019, 11:38am UTC](https://forum.mattermost.com/t/solved-docker-compose-mattermost-with-nginx-proxy-dont-work/7081/12 "2019-04-16T11:38:20Z")

</div>

> [@Felix](#):
>
> ERROR: yaml.parser.ParserError: while parsing a block mapping

its run now :). thanks for all your support.
