Nginx reverse-proxy shows only default page

Hello
with this vhost config I only get the nginx default page. How could I get to the NC login page?

server {
  listen 443 ssl ;
  listen [::]:443 ;
  # replace domain.net with your domain
  server_name subdomain.domain.ch;

  # the rest of your TLS configuration goes here
  ssl_certificate_key /etc/letsencrypt/live/domain.ch/privkey.pem; # managed by Certbot
  ssl_certificate     /etc/letsencrypt/live/domaint.ch/fullchain.pem; # managed by Certbot

  location / {
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Server $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Protocol $scheme;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_buffering off;

      proxy_pass http://192.168.0.25;
  }
}

I don’t know where to proxy_pass to. Nextcloud has no port.

You would pass it to the address and port of the other web server that you have running Nextcloud directly. This is highly dependent upon your setup, so I can’t be more specific based on the info provided.

1 Like

I don’t have another webserver. I use the same webserver I use for Nextcloud. I thought that should work. But maybe I was wrong.

Well… again, with no details, I can’t be any more specific about what you should do. How about you start from the top.

A reverse proxy means that the web server is passing the connection back to another web server.

1 Like

I’m running Ubuntu server 22.04, nginx 1.18 and NC25. nginx has been left in it’s default state except the nextcloud conf file. Well, there’s another subdomain running, also proxied, but that one works fine (Navidrome), since I can address a port. What more info should I provide? The config.php?

In this case you you don’t need a reverse proxy configuration for Nextcloud. Reverse proxy configurations are only needed, if you want to proxy (pass) the connection to another web server, which can either run on the same server (listening on another port) or on a diffrent server (listening on another IP)

That’s because Navidrome provides it’s own web server, but Nextcloud doesn’t, or at least it doesn’t, if you have installed it manually from the zip file.

I’m not very familiar with configuring multiple server blocks in nginx, because I mainly use Apache. But I’m sure you can add one sever block for Navidrome, that proxies the connection to the web server of Navidrome, and then add another server block, using a “normal” server configuration instead of a reverse proxy configuration, that serves the local folder where Nextcloud is installed.

1 Like

In this case you you don’t need a reverse proxy configuration for Nextcloud.

This is it! Now that you’ve mentioned it, it makes totally sense and that’s what I didn’t understand.

Yes, I’ve installed it manually following Xiao’s guide. Now I use exactly his nextcloud.conf file except that it listens on 443 instead of 80 plus the LE cert instructions. And it works! Well, almost…

It works only, when I mute my navidrome.conf. If I have it running, the Nextcloud subdomain also points to Navidrome. Probably I need to set a directive in either conf file to avoid that?

My Navidrome conf is exactly the same, I posted above for Nextcloud.

Is Navidrome running on the same server, where Nextcloud and nginx is installed? If so, try to use localhost or 127.0.0.1 instead of the actual IP address of the server. Also you have to add the port like this…

proxy_pass http://localhost:4533;

or

proxy_pass http://127.0.0.1:4533;

Other than that I’m not sure, because I’m not very familiar, with neither nginx or Navidrome.

EDIT:
You also have to use a different subdomain for the Navidrome config, otherwise nginx cannot know which server block it should use, and will probably always try to use the first one.

Is Navidrome running on the same server, where Nextcloud and nginx is installed?

Yes.

Also you have to add the port like this…

Neither of them. Like this proxy_pass http://192.168.0.25:4533;

But, I might have found the solution by simply deleting the “default server” out of Navidrome’s conf file. After I did that, unless this is a stupid idea for whatever reason, it works as expected (just had to clean my browser cookies). So thanks to your explanation I learned something important and now have a working server again. Thank you!

1 Like

No quite the opposite, I think it’s a good idea to delete / disable the default server. :slight_smile:

Ah, ok.

But now, when I had another look into Navidrome’s conf file, the default server directive is back in (but it still works). Really? Could that be? Well, but it runs, what is most important. I will try to understand, what is going on under the hood.

Not sure, because as I said, I’m not an expert on nginx.

If you want to learn how it works, I would recommend to setup a test server, maybe in a VM, install nginx on it and setup a few test sites (for a start, it can be as simple as a few “Hello world” html files). Just play around with diffrent configuartions and see how it behaves. There is also a ton of guides and how-tos about nginx out there…

Using NGINX you COULD utilize the FPM feature of NGINX, and use FPM-PHP on a different host (where you also installs Nextcloud). With that setup, you basically uses the NGINX as the webserver, and connects to the PHP server over network. This will save you a little bit of overhead, of running two webservers, where your current NGINX is used as a reverse proxy. A setup like that is good for spreading the load, and isolating resources. Example:
One frontend->several webapss.

One webapp uses a lot of resources from time to time, which in a traditional webserver setup serving several apps from the same host, shares all the same resources, and this would severely effect performance of the other apps. Instead:
One webserver serves only the HTML response, and the backend services are all running on several seperate hosts, hence one heavy loaded webapp will use the resources on the host of that app only.

Long story short: It makes sense to seperate your frontend from your backend by using NGINX as a frontend with its own reserouces, and the backends seperated with dedicated resources. NGINX supports both reverse proxy and FPM, to achieve this.

If you want to learn how it works, I would recommend to setup a test server,…

Good idea, I’ll do that. But first I would like to install coturn for Talk on my server. This seems to be adventurous what I’ve read so far. Thank’s again.

That’s a good point. But I just run those 2 apps and probably would be kind of an overkill split resources for me.