# Nginx configuration for discourse

**URL:** https://meta.discourse.org/t/nginx-configuration-for-discourse/59962
**Category:** Self-hosting
**Created:** [2017年三月27日 12:53 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962 "2017-03-27T12:53:05Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年三月27日 12:53 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/1 "2017-03-27T12:53:05Z")

</div>

I have isntalled discourse on a VPS. Now I want to run a nodeJS app running on port 3030 on the vps.  
I have added the following to the `/etc/nginx/sites-available/default`:

```plaintext
location /recommender/ {
	
	proxy_pass http://localhost:3030; 
	
	}

```

after that, when I goto `myPublicIP/recommender` I received the rails error that the page does not exist. But I want to receive the nginx error.  
The configuration worked well on my local but didn’t work well on vps.

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年三月31日 18:17 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/2 "2017-03-31T18:17:46Z")

</div>

does any body know where the config file of nginx is exactly located?  
Perhapse I am changing the wrong folder.

---

<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: [2017年三月31日 18:24 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/3 "2017-03-31T18:24:08Z")

</div>

Did you follow the recommended Docker-based install? Did you set up a reverse proxy [like so](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247)?

Did you navigate to `myPublicIP/recommender` by clicking a link in Discourse or directly, by entering it in the navigation bar of a new tab?

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年三月31日 18:34 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/4 "2017-03-31T18:34:25Z")

</div>

outside of the Docker I didn’t find nginx folder.  
I think nginx is installed on Docker

---

<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: [2017年三月31日 18:38 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/5 "2017-03-31T18:38:57Z")

</div>

If you want to host non-Discourse sites on the same host, you’ll need to set up a reverse proxy. Simply follow [these steps](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) to do so. In the end, you’ll have an nginx running outside of Docker to fiddle with 🙂

(Please note that Discourse and your external website should use different domains, or links from Discourse will break.)

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年三月31日 18:50 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/6 "2017-03-31T18:50:58Z")

</div>

Can I install the app inside the docker?  
This is simple nodeJS app that I can run it every where.  
Can I use docker for my small app?

---

<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: [2017年三月31日 18:59 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/7 "2017-03-31T18:59:52Z")

</div>

> [@Alavi1412](#):
>
> Can I install the app inside the docker?

No. (It’s not recommended. It would be _possible_, but not very easy or worthwhile.)

> [@Alavi1412](#):
>
> Can I use docker for my small app?

Yes, but if you don’t know that already, you might rather follow the link that @fefrei pointed to. If you put your app in a container, you would still need another Nginx (perhaps running in a Docker container) to reverse proxy to Discourse and your app.

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年四月3日 11:10 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/8 "2017-04-03T11:10:02Z")

</div>

@fefrei  
We have installed discourse with [this](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md) process.  
Doing the [following](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) will solve my problem or not?  
does it may cause error?  
should we delete the previous nginx or not?  
Are these steps SAFE?(Very Important)

---

<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: [2017年四月3日 11:18 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/9 "2017-04-03T11:18:58Z")

</div>

These steps should be up-to-date and are quote popular, so they are relatively safe. Still, I’d always recommend having a backup!

> [@Alavi1412](#):
>
> should we delete the previous nginx or not?

Which previous `nginx`?

---

<div class="post-metadata">

### Author: ![Alavi1412](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alavi1412/32/67721_2.png) [@Alavi1412](https://meta.discourse.org/u/Alavi1412)
#### Post date: [2017年四月3日 11:21 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/10 "2017-04-03T11:21:25Z")

</div>

> [@fefrei](#):
>
> Which previous nginx?

the nginx inside the docker

---

<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: [2017年四月3日 11:26 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/11 "2017-04-03T11:26:11Z")

</div>

No – with Discourse, you should (almost) never need to modify anything within its Docker container 🙂

---

<div class="post-metadata">

### Author: ![terraboss](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/terraboss/32/381157_2.png) [@terraboss](https://meta.discourse.org/u/terraboss)
#### Post date: [2018年一月22日 01:08 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/12 "2018-01-22T01:08:10Z")

</div>

Hello guys,

can someone help me to solve [this old “issue”](https://meta.discourse.org/t/howto-open-pdf-files-in-same-browser-window/25823), by explaining me where I can find and edit the nginx config? I found some snippet, that could help me:

[https://stackoverflow.com/a/31321716](https://stackoverflow.com/a/31321716)

> I added to my mime.types file:
> 
> ` audio/x-wav wav;`
> 
> In my nginx config:
> 
> ```
> location ~ \.wav$ {
> add_header Content-Disposition "inline";
> }
> 
> ```

It would be nice to view the pdf file inside browser window itself. I guess, it must look like this …

` application/pdf pdf;`

```
location ~ \.pdf$ {
  add_header Content-Disposition "inline";
}

```

What would be the most elegant way to realise this?

Thanks in advance!

---

<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: [2018年一月22日 01:17 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/13 "2018-01-22T01:17:26Z")

</div>

[Run other websites on the same machine as Discourse](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/17247) has an example of how to change the Nginx config inside the container.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2020年四月11日 13:51 UTC](https://meta.discourse.org/t/nginx-configuration-for-discourse/59962/14 "2020-04-11T13:51:52Z")

</div>


