You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/18 11:22:55 UTC

[GitHub] [apisix] tzssangglass commented on issue #7735: help request: 在apisix中如何实现这段Nginx的配置

tzssangglass commented on issue #7735:
URL: https://github.com/apache/apisix/issues/7735#issuecomment-1219374268

   > 如何实现以上的if语句判断,根据不同的method需要添加不同的header(通过创建多个不同的路由规则?)
   
   yes, for example
   
   add route route:
   
   ```shell
   curl http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "methods": ["GET"],
       "uri": "/get",
       "plugins": {
           "proxy-rewrite": {
               "headers": {
                   "X-Api-Version": "v1",
                   "X-Api-Engine": "apisix",
                   "X-Api-useless": ""
               }
           }
       },
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "httpbin.org:80": 1
           }
       }
   }'
   ```
   
   test:
   
   ```
   curl http://127.0.0.1:9080/get
   {
     "args": {},
     "headers": {
       "Accept": "*/*",
       "Host": "127.0.0.1",
       "User-Agent": "curl/7.84.0",
       "X-Amzn-Trace-Id": "Root=1-62fe205b-636fcc8774d92f5936fc6bd5",
       "X-Api-Engine": "apisix",
       "X-Api-Version": "v1",
       "X-Forwarded-Host": "127.0.0.1"
     },
     "origin": "127.0.0.1, xxxxxx",
     "url": "http://127.0.0.1/get"
   }
   ```
   
   
   
   > 如何设置proxy_set_header(通过proxy-rewrite插件?)
   > 如何设置proxy_pass_header
   ref: https://github.com/apache/apisix/blob/master/docs/en/latest/customize-nginx-configuration.md
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org