0

I have a docker compose file and an nginx.conf file. The nginx is able to route the request correctly in the below given case

events {}
http {
    upstream weaviate {
            server weaviate:5555;
    }

    server {

        listen 80 default_server;
        listen [::]:80 default_server;

        location / {
            proxy_pass http://weaviate;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            break;
        }

        location /health-check {
          return 200;
          access_log off;
        }
    }
}

In this case, calling localhost route me to the weaviate page. But, if make a small change so that I can call localhost/weave, it is not working.

events {}
http {
    upstream weaviate {
            server weaviate:5555;
    }

    server {

        listen 80 default_server;
        listen [::]:80 default_server;

        location /weave {
            proxy_pass http://weaviate;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            break;
        }

        location /health-check {
          return 200;
          access_log off;
        }
    }
}

It is giving me {"code":404,"message":"path /weave was not found"}

What difference does

location /weave/ {
            proxy_pass http://weaviate/; 

makes

1 Answers1

0

If you are adding a new location block to your nginx.conf file, such as:

location /weave {
    proxy_pass http://weaviate;
    ...
}

Then there are a few things you need to make sure of:

Make sure that your application is actually listening on the correct endpoint. If you have added a new location block, you will need to make sure that your application is listening on /weave instead of just /. You can check this in your application code or configuration.

Make sure that the new location block is actually being matched. When nginx receives a request, it tries to match the request URI against each location block in the order they appear in the configuration file. If it finds a match, it uses the configuration inside that block to process the request. If it does not find a match, it uses the configuration in the default location block (which is the one you provided in your original question). Make sure that the new location block is appearing before the default location block in your configuration file.

Make sure that you are requesting the correct URI. If you have added a new location block, you will need to make sure that you are requesting the correct URI in your browser or client application. In this case, you should be requesting ##

http://localhost/weave instead of just http://localhost.

If you have made these changes and are still having issues, you can check the nginx logs to see if there are any errors or warnings that may be helpful in troubleshooting the issue.