Nginx proxy_pass标头

时间:2019-03-13 13:29:22

标签: nginx http-headers reverse-proxy

这是我的位置配置的一部分:

        location /web {
                proxy_pass http://192.168.1.141:8079/gateway/web;
                add_header "TEST" 1;
                proxy_pass_request_headers      on;
                if ($request_method ~* "(GET|POST)") {
                add_header "Access-Control-Allow-Origin"  *;
                add_header "TEST" 1;
                }
                if ($request_method = OPTIONS ) {
                add_header "Access-Control-Allow-Origin"  *;
                add_header "TEST" 1;
                add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
                add_header "Access-Control-Allow-Headers" "Origin, X-Requested-With, Content-Type, Accept";
                return 200;
   }

我试图配置将TEST标头添加到/ web之外的每个请求中,因此,如果链接包含“ / web”,请在所有请求中添加TEST标头,即

/web/mail/*
/web/auth/*
/web/people/*

0 个答案:

没有答案