Location configuration is invalid when nginx is accessed by domain name

here is the configuration section. Location is configured to access the static file in the / test/files/ directory when / file/ matches. The test uses ip access to download files normally, but it does not seem to take effect when using the domain name. The request is reversed and proxied to tomcat for processing, and then 404.

is returned.
server
  {
    listen     80;
    server_name host.com;
    root  /var/www/html;
    proxy_ignore_client_abort on;

    -sharplimit_conn   crawler  20;

    location ^~ /file/ {
        alias  /test/files/;
    }

    location / {
           proxy_set_header X-real-ip $remote_addr;
           proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header  Host $http_host;
           proxy_pass http://tomcat_svr;
    }
}
Mar.30,2021

try
location / file {

}
or
location ^ / file/ {
alias / test/files;
}
try both. I don't know which directory your files are in

.

has been solved, and the reason for abnormal operation and maintenance will not be posted.

Menu