Nginx configuration for discourse

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.

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

1 Like

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?

1 Like

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

1 Like

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.)

1 Like

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?

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.

2 Likes

@fefrei
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)

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?

1 Like

the nginx inside the docker

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

2 Likes

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!

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

2 Likes