我想在http块中提供特定文件,但是我的nginx配置仍然将我重定向到https。这是我的http块配置:
server {
listen 80;
server_name example.com;
location /files/myfile.gz {
alias /home/user/project/myfile.gz;
}
location / {
return 301 https://example.com$request_uri;
}
}
答案 0 :(得分:1)
这是因为您的第二个位置规则仍将与第一个/files/myfile.gz
如果您希望从Nginx提供单个文件,请尝试
server {
listen 80;
server_name example.com;
location =/files/myfile.gz {
alias /home/user/project/myfile.gz;
}
location / {
return 301 https://example.com$request_uri;
}
}