Using two web servers—two unix sockets needed?

AI-generated summary

Using two web servers—two unix sockets needed?

prostasia wants to serve the same Discourse instance on two different networks using two web servers. csmu suggests setting the upstream to the same server using nginx. However, justin points out that using two different hostnames may cause issues with routing, email, and link generation.

prostasia is willing to accept a degraded user experience for the second hostname and suggests using webserver rewrites to handle broken links. Falco mentions a middleware that enforces the site hostname, making this approach challenging.

prostasia reveals that the goal is to make the forum accessible on the Tor network. Falco shares a relevant discussion on meta.discourse.org that may provide a solution.

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.

We run nginx in front of discourse.

Setting the upstream to the same server would probably work.

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

Will the hostname be the same in both instances?

No it will be different.

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.

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.

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

Why do you want do do this?

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

So check this out