# Using two web servers—two unix sockets needed?

**URL:** https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956
**Category:** Self-hosting
**Created:** [June 21, 2019, 3:17am UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956 "2019-06-21T03:17:12Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![prostasia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/prostasia/32/147385_2.png) [@prostasia](https://meta.discourse.org/u/prostasia)
#### Post date: [June 21, 2019, 3:17am UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/1 "2019-06-21T03:17:12Z")

</div>

Hi, my use case is a bit strange. I want to have two different web servers serving the same Discourse instance on two different networks.

Can I use the same container and socket (/var/discourse/shared/standalone/nginx.http.sock) for both, or do I have to configure a separate container and/or unix socket for the second web server?

Thanks.

---

<div class="post-metadata">

### Author: ![csmu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csmu/32/124581_2.png) [@csmu](https://meta.discourse.org/u/csmu)
#### Post date: [June 21, 2019, 4:24am UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/2 "2019-06-21T04:24:59Z")

</div>

> [@prostasia](#):
>
> Can I use the same container and socket (/var/discourse/shared/standalone/nginx.http.sock) for both

We run nginx in front of discourse.

Setting the upstream to the same server would probably work.

```plaintext
upstream discourse {
    server 127.0.0.1:8080;
		keepalive 32;
}

```

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [June 21, 2019, 6:39am UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/3 "2019-06-21T06:39:41Z")

</div>

Will the hostname be the same in both instances?

---

<div class="post-metadata">

### Author: ![prostasia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/prostasia/32/147385_2.png) [@prostasia](https://meta.discourse.org/u/prostasia)
#### Post date: [June 21, 2019, 2:30pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/4 "2019-06-21T14:30:16Z")

</div>

No it will be different.

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [June 21, 2019, 2:54pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/5 "2019-06-21T14:54:27Z")

</div>

You’re going to run into some issues having two different hostnames. Discourse is built to use one hostname, so not only is routing involved, but email, generation of links, etc.

Going the route you want, one path of access is going to get the correct hostname from Discourse, and one will not, thus resulting in lots of broken things.

---

<div class="post-metadata">

### Author: ![prostasia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/prostasia/32/147385_2.png) [@prostasia](https://meta.discourse.org/u/prostasia)
#### Post date: [June 21, 2019, 7:19pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/6 "2019-06-21T19:19:09Z")

</div>

Darn. Any other suggestions? It’s fine if emails use only the original hostname, and maybe I could handle the links being wrong using webserver rewrites. It doesn’t matter if the second hostname is a slightly degraded user experience provided that the messages are all visible and posting via the website is possible.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [June 21, 2019, 8:05pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/7 "2019-06-21T20:05:36Z")

</div>

We also recently added a middleware that will enforce the site hostname.

Why do you want do do this?

---

<div class="post-metadata">

### Author: ![prostasia](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/prostasia/32/147385_2.png) [@prostasia](https://meta.discourse.org/u/prostasia)
#### Post date: [June 21, 2019, 8:31pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/8 "2019-06-21T20:31:19Z")

</div>

It’s because we want to make the forum accessible on the Tor network.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [June 21, 2019, 9:50pm UTC](https://meta.discourse.org/t/using-two-web-servers-two-unix-sockets-needed/120956/9 "2019-06-21T21:50:50Z")

</div>

So check this out

> [@Forcing hostname has broken support for Onion Services](https://meta.discourse.org/t/forcing-hostname-has-broken-support-for-onion-services/102419/4):
>
> Fundamentally the problem is we expect Discourse sites just to have 1 domain. The reason for this is that we send out emails and have to pick a domain we can not pick random. I am not following why not have the onion address as your hostname. If you really really want to enable this ninja I am allowed to have 2 domains going feature, you can use a plugin, example of a commit that made this work for my blog is here: [https://github.com/SamSaffron/blog/commit/d09f5ea409e4a3a5d4905f511273bc0566e2…](https://github.com/SamSaffron/blog/commit/d09f5ea409e4a3a5d4905f511273bc0566e21cff)
