0

I'm trying to set up a test server block using nginx. I've tried many ways, but test.myserver.com always shows me a 404. My goal is to be shown the index.html in /var/www/test/html/index.html.

This is what I have so far:

server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #
        listen 443 ssl;
        listen [::]:443 ssl;


        root /var/www/test;
        index index.html index.htm index.nginx-debian.html;
        server_name test.myserver.com www.test.myserver.com;

        location ^~ /html {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files index.html $uri $uri/ / =404;
        }

        location / {
                index /html/index.html;
        }

As you can see, I'm trying to different ways already. I got the idea with the ^~ folder location from here.

So: why is nginx giving me 404s and how would I fix that?

Timon
  • 151
  • 1
  • 5

1 Answers1

0

So I finally figured out something was messed up with my default server block configuration. Basically, for reasons unknown to me, my preexisting nextcloud instance appears to have taken over as default server. That alone would probably not have done much, but the /etc/nginx/conf.d/nextcloud.conf file, which sets nextcloud as the default server, integrates the other server blocks as described in /etc/nginx/sites-enabled and adds the same tags the nextcloud server block runs under to them. Once I removed a whole bunch of unnecessary location ~ and location / tags from the test.myserver.com server block within /etc/nginx/conf.d/nextcloud.conf (which weren't in the sites-available version), everything started working proper.

Timon
  • 151
  • 1
  • 5