zoukankan      html  css  js  c++  java
  • 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; 参数导致,删除后即恢复正常,如果使用该参数建议放到具体的模块中使用
  • 相关阅读:
    Missing Ranges
    springboot整合quartz
    Quartz01
    springboot整合jap
    springboot集成redis
    springboot整合drui、mybatis、pagehelper
    springboot模板
    SpringBoot入门
    Java注解简介
    Git02(ssh key的配置和使用、idea配置并使用Git)
  • 原文地址:https://www.cnblogs.com/dzc-/p/15342228.html
Copyright © 2011-2022 走看看