# Using Multiple Websites with Nginx + Discourse

**URL:** https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467
**Category:** Self-hosting
**Created:** [April 3, 2018, 2:19pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467 "2018-04-03T14:19:35Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 2:19pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/1 "2018-04-03T14:19:35Z")

</div>

I’ve managed to set up Nginx to use Discourse as its main site… however i’m having trouble adding addition sites with a prefix, for example [addons.domain.com](http://addons.domain.com)

I’ve followed multiple tutorials online and all of them cause the site to not be reached? (my Discourse site is still reachable) how could i fix this?

Alternatively is there a way i could host a HTML site within the Discourse files? for example [domain.com/othersite](http://domain.com/othersite)? when i’ve tried to do this in the past it just links to my discourse site with a page not found error.

Thanks!

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 3, 2018, 3:43pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/2 "2018-04-03T15:43:39Z")

</div>

Follow these instructions to set up an instance of Nginx on the host:

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247):
>
> @pfaffman edited this heavily 2022.02.24. Blame me if it’s broken. If you want to run other websites on the same machine as Discourse, you need to set up an extra NGINX or HAProxy proxy in front of the Docker container. NOTE: This is for advanced admins This guide assumes you already have Discourse working - if you don’t, it may be hard to tell whether or not the configuration is working. You cannot use ./discourse-setup to set up Discourse if another server is using port 80 or 443. You will…

Once this is complete, you can configure this Nginx instance to also serve any other domain you want, either directly or by proxying to another server 🙂

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 4:15pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/3 "2018-04-03T16:15:15Z")

</div>

Hey, thats what i used for making Discourse work with it..

I was unsure whether i’d do that again for another address? if i do would i just use virtually the same code and change the filename from “discourse.conf” to “blahblah.conf”?

Thanks for the response!

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 3, 2018, 4:17pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/4 "2018-04-03T16:17:18Z")

</div>

What do you want to run on the second domain? If it’s Discourse, you’ll have to install a second instance (or use multisite), and have a second, similar configuration file. If it’s something different, the configuration will be different, of course 😉

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 4:23pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/5 "2018-04-03T16:23:48Z")

</div>

Yeah its something different. Just something i’ve coded myself.

Which is where i’m having problems… i’ve tried multiple guides to try and add a 2nd site using a prefix like “addons.” but it doesn’t work (Site cannot be reached)?

Here’s an example tutorial that i’ve used: [How To Add New Site Into Your Nginx-based Ubuntu Server - ServerMom](http://www.servermom.org/how-to-add-new-site-into-your-nginx-based-ubuntu-server/)

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 3, 2018, 4:29pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/6 "2018-04-03T16:29:52Z")

</div>

What domain are you trying to add?

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 4:48pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/7 "2018-04-03T16:48:44Z")

</div>

Currently have Discourse on gidentity .net _(had to space the link because of post requirements for new users)_

I want to use the custom stuff on either [addons.gidentity.net](http://addons.gidentity.net) or [gidentity.net/addons/](http://gidentity.net/addons/) (dont think the 2nd one is possible because of Discourse)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 3, 2018, 5:02pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/8 "2018-04-03T17:02:02Z")

</div>

If you followed the guide linked above, you just need to configure another site in the Nginx on the server (nothing to do with Discourse).

Google something like “configuring multiple sites in nginx”.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 3, 2018, 5:03pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/9 "2018-04-03T17:03:52Z")

</div>

What’s currently missing is DNS for [addons.gidentity.net](http://addons.gidentity.net/). You should set up an A record for this domain that points to `185.38.148.133` 🙂

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 5:54pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/10 "2018-04-03T17:54:43Z")

</div>

That must be it! Will try that now, thanks.

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 6:08pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/11 "2018-04-03T18:08:31Z")

</div>

> [@fefrei](#):
>
> What’s currently missing is DNS for [addons.gidentity.net](http://addons.gidentity.net/). You should set up an A record for this domain that points to `185.38.148.133` 🙂

That fixed the problem.  
Little unrelated… but would i have to update my letsencrypt to allow for the prefix?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 3, 2018, 6:28pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/12 "2018-04-03T18:28:41Z")

</div>

You’ll need to install Let’s Encrypt in the Nginx on the computer (not the Discourse container).

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 3, 2018, 7:28pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/13 "2018-04-03T19:28:54Z")

</div>

You can find some hints on how to do that as part of the following tutorial (but you’ll need to skip some unrelated parts):

> [@Add an offline page to display when Discourse is rebuilding or starting up](https://meta.discourse.org/t/adding-an-offline-page-when-rebuilding/45238):
>
> warning This guide is intended for advanced users, who are already using nginx outside the docker container. By following this guide you make your setup more complicated and will lose some speed benefits like HTTP2 if you’re not running Ubuntu 16.04 or later. Proceed with caution! When Discourse is rebuilding or starting up, your users will usually either see an error message from their browser… …or a not-so-nice 502 error message from Nginx: If you’re a perfectionist …

---

<div class="post-metadata">

### Author: ![Zarken](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zarken/32/93596_2.png) [@Zarken](https://meta.discourse.org/u/Zarken)
#### Post date: [April 3, 2018, 9:45pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/14 "2018-04-03T21:45:40Z")

</div>

Thought I had this sorted but apparently not.  
Going to the url [addons.gidentity.net](http://addons.gidentity.net) no longer displays an error however it automatically forwards to gidentity. net (remove space after . - posting requirements) what could be the cause of this?

EDIT - my DNS records = [https://puu.sh/zVErv/93ed69a2ac.png](https://puu.sh/zVErv/93ed69a2ac.png)

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [April 4, 2018, 4:11am UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/15 "2018-04-04T04:11:02Z")

</div>

Such a redirect probably means that your configuration isn’t appplying and the wrong one is used.

- Did you link your new file to show up in the `sites-enabled`-folder?
- Did you remember to reload Nginx after that? Did that succeed or show an error?

If these steps don’t help, can you post your configuration files here so we can have a look? 🙂 (They shouldn’t contain sensitive information, but please double-check.)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/using-multiple-websites-with-nginx-discourse/84467/16 "2024-06-08T12:37:36Z")

</div>

This topic was automatically closed after 2257 days. New replies are no longer allowed.
