Nginx not reachable by browsers, but Nextcloud still working

Hello,

I’m facing yet another strange problem: my Nginx installation suddenly is not reachable by any browser whatsoever any more, while at the same time every Nextcloud synchronisation app still works perfectly.

Some details about my server:

  • Armbian 26.2.1 trixie
  • Nginx
  • Nextcloud (latest)
  • MariaDB
  • Letsencrypt (updated 3 weeks ago)

Until a few days ago, every browser on any of my devices could call the web gui of my server and Nextcloud presented its login page. Then, after the latest OS update, suddenly browsers tell my they can’t connect to the server, but every synching app on any of devices still work perfectly. And I can even access my files on the server by using FolderSync’s¹ internal file browser.

It is just the browsers that can’t connect any more, no matter which browser, no matter which device! There is no error message in the appropriate log files, neither in the system log, nor in Nextcloud’s own log, and the message that the browsers present is simply some variation of “I can’t connect to server”. No specific reason, no error code.

This is more than strange to me. I would get it if synching apps would have stopped working as well, but that is not the case. Does any one have an explanation for this mystery? If you need more information, just let my know!

Many thanks in advance!

(¹ Synching app on Android.)

Hello, do you have a screenshot or details on the browser error page?

Also, what are you seeing using the network developper tools from your browser as an error message? e.g. on this page, the error is a host resolution error:

Thanks for your reply! My time is a bit limited at the moment, but I will provide more information in the next days.

When I said, none of my browsers on any device can not connect any more, they behave as if I entered a completely invalid address. They just show the message about not being able to connect. No 404 or other big letter error.

But meanwhile I might have a clue to what’s going on:

My /etc/nginx/sites-available/nextcloud includes the use of a port different from 443:

server {
listen 12345 ssl; # Just an example!!!
server_name myserver.name

}

All of my apps that connect to Nextcloud for data synching and all of my browsers then used this address: https://myserver.name:12345. This setting has been working flawlessly for months. No complaining by any app or browser whatsoever.

Until a few days ago…

Now, I see this: if I tell my browser to go to https://myserver.name:12345 the address bar changes itself to just https://myserver.name, without the provided port number, and the browser can’t connect.

As a quick and dirty solution I simply added port 443 as well, and suddenly my browsers can connect again:

server {
listen 12345 ssl; # Just an example!!!

listen 443 ssl;
server_name myserver.name;

}

It would be interesting to find out why just the browsers (any browser!) are effected, while other apps still are working without adding port 443 to the servers listening.

My guess would be that an update of nginx brought a change to some redirecting rule, so it does not work any more the same way as it did before.

Thank you for reaching back on this topic!

Glad if you could find a solution for this. Let me know if you’d want help in investigating further.

Thanks for your offer to help me investigating further! Although the server is reachable by browsers again, I certainly would like to know what has (been) changed, why only browsers are effected, and how to prevent such a malfunction to happen again.

Hello, from my understanding of your situation, I’d guess that maybe a behaviour changed on the Nextcloud side, rather than NGINX (if you did not change the conf since it was working). From my small experience, Nextcloud handles quite badly being exposed on non 443 port for HTTPS. Despite you using NGINX to listen on an arbitrary port (say 12345 to take your example), you cannot control easily whether Nextcloud could just emit redirect responses to the standard 443 port, instructing any browser to just go to port 443 (the standard when no port is shown on URL bar with HTTPS) instead of 12345.

You could check this with for example the following command:

curl -i https://myserver.name:12345/

If you see an output such as :

HTTP/1.1 302 Found
Location: https://myserver.name/
Content-Length: 0
Connection: close

Then there is something (NGINX, with a custom rule, or Nextcloud) that asks your browser to leave the port 12345 and go to port 443.

Does this help?