# Nginx + discourse

**URL:** https://meta.discourse.org/t/nginx-discourse/35444
**Category:** Self-hosting
**Created:** [November 11, 2015, 3:14am UTC](https://meta.discourse.org/t/nginx-discourse/35444 "2015-11-11T03:14:02Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Honey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honey/32/122121_2.png) [@Honey](https://meta.discourse.org/u/Honey)
#### Post date: [November 11, 2015, 3:14am UTC](https://meta.discourse.org/t/nginx-discourse/35444/1 "2015-11-11T03:14:03Z")

</div>

On my vps I use primarily nginx for a php type forum. I also am running NodeBB (node.js) proxied through nginx. The point being port 80 belongs to nginx. I believe this will work, but I’d like some feedback.

app.xml

```plaintext
## which TCP/IP ports should this container expose?
expose:
  - "81:80" # fwd host port 80 to container port 80 (http)
  - "2222:22" # fwd host port 2222 to container port 22 (ssh)[/code]

nginx
[code]server {
    listen 80;

    server_name example.com;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:81/;
        proxy_redirect off;

        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}
```

Thoughts?

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [November 11, 2015, 3:33am UTC](https://meta.discourse.org/t/nginx-discourse/35444/2 "2015-11-11T03:33:07Z")

</div>

You might want to take a look at this post for more information:

> [@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…

Haven’t done it myself, but looks pretty detailed and might send you in the right direction for your project.

---

<div class="post-metadata">

### Author: ![Honey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honey/32/122121_2.png) [@Honey](https://meta.discourse.org/u/Honey)
#### Post date: [November 11, 2015, 3:41am UTC](https://meta.discourse.org/t/nginx-discourse/35444/3 "2015-11-11T03:41:58Z")

</div>

I’m aware of that, but I don’t think you’ve answered my question (your post also got cut off)

Do you see the above configuration as a possible working solution? Discourse is not yet installed and I plan on using the above **app.xml** to install it. The nginx should then act as a proxy.

If you don’t know, please say you don’t know. That is a perfectly acceptable answer.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 11, 2015, 4:05am UTC](https://meta.discourse.org/t/nginx-discourse/35444/4 "2015-11-11T04:05:26Z")

</div>

Post is not cut off, it is a summary generated from the link. Click through to view. Like any other link on the web..

You can also click on the top of the summary anywhere around the chevron arrow to expand it in place, rather than visiting the URL.

---

<div class="post-metadata">

### Author: ![Honey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honey/32/122121_2.png) [@Honey](https://meta.discourse.org/u/Honey)
#### Post date: [November 11, 2015, 4:23am UTC](https://meta.discourse.org/t/nginx-discourse/35444/5 "2015-11-11T04:23:29Z")

</div>

Alright, I missed that.

I decided to try my configuration anyways and answer my own question. The answer is YES it works using my configuration found in post #1

> [@Nginx + discourse](https://meta.discourse.org/t/nginx-discourse/35444):
>
> On my vps I use primarily nginx for a php type forum. I also am running NodeBB (node.js) proxied through nginx. The point being port 80 belongs to nginx. I believe this will work, but I’d like some feedback. app.xml ## which TCP/IP ports should this container expose? expose: - "81:80" # fwd host port 80 to container port 80 (http) - "2222:22" # fwd host port 2222 to container port 22 (ssh)[/code] nginx [code]server { listen 80; server\_name example.com; location / { …

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [November 11, 2015, 4:27am UTC](https://meta.discourse.org/t/nginx-discourse/35444/6 "2015-11-11T04:27:10Z")

</div>

> [@Honey](#):
>
> I’m aware of that

Let us know what prior research you’ve done in the future so we can skip recommending anything you might have already seen.

> [@Honey](#):
>
> please say you don’t know

See:

> [@wesochuck](#):
>
> Haven’t done it myself

> [@Honey](#):
>
> I plan on using the above app.xml to install it.

Do you mean app. **yml**? From my linked article:

> [@Run other websites on the same machine as Discourse](https://meta.discourse.org/t/run-other-websites-on-the-same-machine-as-discourse/17247/1):
>
> This is where we change how Discourse actually gets set up. We don’t want the container listening on ports - instead, we’ll tell it to listen on a special file.
> 
> Change your /var/discourse/containers/app.yml to look like this:

So, I would say that while your proposed app. **yml** file might work, it would not be the preferred/supported method of doing what you’re trying to accomplish.

---

<div class="post-metadata">

### Author: ![Honey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/honey/32/122121_2.png) [@Honey](https://meta.discourse.org/u/Honey)
#### Post date: [November 11, 2015, 4:30am UTC](https://meta.discourse.org/t/nginx-discourse/35444/7 "2015-11-11T04:30:38Z")

</div>

I do apologize. I’m new to discourse and your post appeared to be cut off. So from my limited perspective it originally appeared to offer no information.

The only question I really was asking was if my config looked like it would work or if anyone else had tried such a configuration?!

I decided to proceed forward and my config does work. 🙂

---

<div class="post-metadata">

### Author: ![wesochuck](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wesochuck/32/108706_2.png) [@wesochuck](https://meta.discourse.org/u/wesochuck)
#### Post date: [November 11, 2015, 4:36am UTC](https://meta.discourse.org/t/nginx-discourse/35444/8 "2015-11-11T04:36:00Z")

</div>

Understood, no hard feelings. Good luck with your setup. Do consider my warning though that _while your method may work_, you might encounter support issues that _this community won’t be able to help you with_ because your setup is different than the one recommended by a Discourse team member.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 11, 2015, 5:32am UTC](https://meta.discourse.org/t/nginx-discourse/35444/9 "2015-11-11T05:32:28Z")

</div>

Seems like @honey knows what s/he is doing. Good work!

---

<div class="post-metadata">

### Author: ![PabloC](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pabloc/32/49633_2.png) [@PabloC](https://meta.discourse.org/u/PabloC)
#### Post date: [February 8, 2016, 7:08pm UTC](https://meta.discourse.org/t/nginx-discourse/35444/10 "2016-02-08T19:08:15Z")

</div>

Thanks @Honey!

Also, it is amazing how well Discourse is indexed on Google.

Kudos guys ☀

---

<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:45pm UTC](https://meta.discourse.org/t/nginx-discourse/35444/11 "2024-06-08T12:45:52Z")

</div>

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