# Mattermost, Nginx and cache

**URL:** <https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989>\
**Category:** Troubleshooting\
**Created:** [May 21, 2018, 5:13pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989 "2018-05-21T17:13:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![egoitz](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@egoitz](https://forum.mattermost.com/u/egoitz)\
**Post date:** [May 21, 2018, 5:13pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/1 "2018-05-21T17:13:49Z")

</div>

Good morning,

I’m using some Mattermost instances proxied by an Nginx service. The Nginx service is configured as you suggested in your doc but with one difference. I have several Mattermost behind one Nginx virtualhost. Can due to this reason and difference with your proposed config, have impredictible results in different Mattermost instances due to cached content?. Each instance is accesed with a completely different URL. For instance :

- [https://mattermost1.matter.most.com](https://mattermost1.matter.most.com)
- [https://mattermost2.matter.most.com](https://mattermost2.matter.most.com)
- [https://mattermost3.matter.most.com](https://mattermost3.matter.most.com)
- [https://mattermost4.matter.most.com](https://mattermost4.matter.most.com)  
.  
.  
.

The question is can something not corresponding to a Mattermost instance, appear there due to a non corresponding to the instance cached content?. Would be better to be using different vhosts?. The main reason I use this config is for simplicity and due to the wilcard certificate I have bought… for avoid having issues with that too…

Have you mates ever experienced issues like this (supposed and not reproduced yet at least) with the cache?.

Best regards,

---

<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:** [May 22, 2018, 5:19pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/2 "2018-05-22T17:19:26Z")

</div>

Hi @egoitz, thank you for reaching out!

Just wanted to give you a quick update that I’ve asked our engineers to take a look at this.

---

<div class="post-metadata">

**Author:** ![egoitz](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@egoitz](https://forum.mattermost.com/u/egoitz)\
**Post date:** [May 22, 2018, 6:35pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/3 "2018-05-22T18:35:05Z")

</div>

Many many thanks!!! 🙂 🙂

---

<div class="post-metadata">

**Author:** ![jespino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jespino/32/7350_2.png) [@jespino](https://forum.mattermost.com/u/jespino)\
**Post date:** [May 22, 2018, 10:19pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/4 "2018-05-22T22:19:36Z")

</div>

Multiple Virtual Hosts with same IP and SSL/TLS is not supported by all the browser, so it can generate some problems deciding which virtual host is really accessed.

You can see an explanation of this here: [https://serverfault.com/a/583253](https://serverfault.com/a/583253)

I’m not 100% sure that’s the problem, but could be related to that.

---

<div class="post-metadata">

**Author:** ![egoitz](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@egoitz](https://forum.mattermost.com/u/egoitz)\
**Post date:** [May 26, 2018, 4:24pm UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/5 "2018-05-26T16:24:03Z")

</div>

Hi Jespino,

The question mainly was… (perhaps I have not explain it properly too… It’s perhaps, more or less a paranoid question perhaps… 🙂 ). If you have a Nginx cache enabled (with the line proposed by you in your docs :

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

And later you have… instead of one backend (for one Mattermost server) several ones… for multiple Mattermost instances… can it cache one Mattermost’s instance info and show into another instance accesses?. The URL for accesing one instance… or another… is different… I mean :

- [https://instance1.mattermost.com](https://instance1.mattermost.com)
- [https://instance2.mattermost.com](https://instance2.mattermost.com)
- [https://instance3.mattermost.com](https://instance3.mattermost.com)  
.  
.  
.

later are proxy\_passed by Nginx to for instance… instance1:8065, instance2:8065… and so on…

Am I in risk of accessing to an user uploaded… imagine a file named… 123.png if someone at another instance of Mattermost and with another URL uploads a 123.png shared file?.

That was the real question 🙂  
Best regards,

---

<div class="post-metadata">

**Author:** ![jespino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jespino/32/7350_2.png) [@jespino](https://forum.mattermost.com/u/jespino)\
**Post date:** [May 28, 2018, 10:08am UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/6 "2018-05-28T10:08:33Z")

</div>

Hi @egoitz,

The question is more about nginx, and it depends on the nginx configuration. You can use the same file because it store the data bound to a cache key which is an MD5 of the `proxy_cache_key` defined by the configuration (by default `$scheme$proxy_host$uri$is_args$args`). Looks like it is safe for multiple virtual hosts using multiple instances behind.

Regards.

---

<div class="post-metadata">

**Author:** ![egoitz](https://avatars.discourse-cdn.com/v4/letter/e/e47774/32.png) [@egoitz](https://forum.mattermost.com/u/egoitz)\
**Post date:** [June 15, 2018, 6:18am UTC](https://forum.mattermost.com/t/mattermost-nginx-and-cache/4989/7 "2018-06-15T06:18:16Z")

</div>

Hi Jespino,

Many many thanks really.

Best regards,
