nginx添加location跳转后不生效

需求:匹配api借口跳转到指定url

nginx配置如下:

upstream sp-api {
        server sp-api:80 max_fails=3 fail_timeout=3;
}
server {
        server_name sp-test.
.com;
        root /usr/local/src/dist/;
        client_max_body_size 50M;
        add_header Access-Control-Allow-Origin '*';
        proxy_buffer_size  128k;
        proxy_buffers   32 32k;
        fastcgi_buffers 32 32k;
        fastcgi_buffer_size 128k;
        proxy_temp_file_write_size 128k;
        proxy_busy_buffers_size   256k;
        access_log /var/log/nginx/sp_access.log;
        error_log /var/log/nginx/sp_error.log;
        proxy_set_header host $host;
      location / {
        autoindex on;
        index index.html;
        try_files $uri /index.html;
      }
      location /msm-api {                         # 这里是新加的location
        proxy_pass https://msm-test.erp.chicv.com/;
      }
      location /sp-api/ {.                          
         proxy_pass http://sp-api/;
      }
      location ~.*\.(htm|html)$ {
       add_header Cache-Control no-store;
       add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
      }

}
上诉配置更新后,发现location没有跳转,具体原因是因为 proxy_set_header host $host; 参数导致,删除后即恢复正常,如果使用该参数建议放到具体的模块中使用