Why is this location rule in the nginx configuration file invalid?

the location rules in the nginx configuration file are as follows:

location = / {
    return 601;  -sharpA
}  
location = /login {  
    return 602;  -sharpB
}  
location ^~ /static/ {  
    return 603;  -sharpC
}  
location ~ \.(gif|jpg|png|js|css)$ {  
    return 604;  -sharpD
}  
location ~* \.png$ {  
    return 605;  -sharpE
}  
location / {  
    return 608;  -sharpH
}

when accessing https://www.mydomain.com/abc.gif, https://www.mydomain.com/abc.png, the server returns 404 instead of the expected 604 or 605,608 (other rules are normal, such as 605 for https://www.mydomain.com/abc.PNG, 601 for https://www.mydomain.com, etc.).

that is to say, rule D is invalid. What is the problem?

Thank you!

Jan.08,2022

when you visit localhost:8888/abc.png with your configuration on my machine, 604 is returned. See screenshot
. I think your nginx configuration is not just above, but other parts are probably working. It is recommended that you comment out other parts and post them to have a look

.

Menu