Nginx configuration for discourse

(SMHassanAlavi) #1

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:

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.

(SMHassanAlavi) #2

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

(Felix Freiberger) #3

Did you follow the recommended Docker-based install? Did you set up a reverse proxy like so?

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?

(SMHassanAlavi) #4

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

(Felix Freiberger) #5

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 to do so. In the end, you’ll have an nginx running outside of Docker to fiddle with :slight_smile:

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

(SMHassanAlavi) #6

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?

(Jay Pfaffman) #7

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

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.

(SMHassanAlavi) #8

We have installed discourse with this process.
Doing the following 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)

(Felix Freiberger) #9

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

Which previous nginx?

(SMHassanAlavi) #10

the nginx inside the docker

(Felix Freiberger) #11

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

(Markus) #12

Hello guys,

can someone help me to solve this old “issue”, by explaining me where I can find and edit the nginx config? I found some snippet, that could help me:

audio - nginx: how to avoid forced downloads in all wav files? - Stack Overflow

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!

(Jay Pfaffman) #13

Running other websites on the same machine as Discourse has an example of how to change the Nginx config inside the container.