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/11/09 11:01:56 UTC

[GitHub] [apisix] chyoong opened a new issue, #8290: help request: How to implement the "proxy_pass: https://$host" feature

chyoong opened a new issue, #8290:
URL: https://github.com/apache/apisix/issues/8290

   ### Description
   
   I want to implement, when matched to cookie_env=a, reverse proxy to the Internet instead of upstream
   ```
   if ($cookie_env = "a") {
       proxy_pass https://$host;
   }
   
   if ($cookie_env = "b") {
       proxy_pass http://nodes;
   }
   ```
   
   This is my traffic-split configuration information, it does not take effect, still access to upstream_id
   ```
   {
     "name": "test",
     "upstream_id": "427820922649445065",
     "plugins": {
       "traffic-split": {
         "disable": false,
         "rules": [
           {
             "match": [
               {
                 "vars": [
                   [
                     "cookie_env",
                     "==",
                     "a"
                   ]
                 ]
               }
             ],
             "weighted_upstreams": [
               {}
             ]
           }
         ]
       }
     }
   }
   ```
   
   ### Environment
   
   APISIX version (run apisix version): apache/apisix:2.99.0-debian
   APISIX Dashboard version, if relevant: apache/apisix-dashboard:2.13-alpine


-- 
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.apache.org

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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308698135

   @chyoong  i give you an example  `curl http://127.0.0.1:9180/apisix/admin/routes/1 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri": "/index.html",
       "plugins": {
           "traffic-split": {
               "rules": [
                   {
                       "match": [
                           {
                               "vars": [
                                   ["http_release","==","new_release"]
                               ]
                           }
                       ],
                       "weighted_upstreams": [
                           {
                               "upstream": {
                                   "name": "upstream_A",
                                   "type": "roundrobin",
                                   "nodes": {
                                       "127.0.0.1:1981":10
                                   }
                               }
                           }
                       ]
                   }
               ]
           }
       },
       "upstream": {
               "type": "roundrobin",
               "nodes": {
                   "127.0.0.1:1980": 1
               }
       }
   }'
   `


-- 
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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1309637959

   > > @chyoong i give you an example
   > > `curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/index.html", "plugins": { "traffic-split": { "rules": [ { "match": [ { "vars": [ ["http_release","==","new_release"] ] } ], "weighted_upstreams": [ { "upstream": { "name": "upstream_A", "type": "roundrobin", "nodes": { "127.0.0.1:1981":10 } } } ] } ] } }, "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }' `
   > 
   > @Hazel6869 Let me give you an example:
   > 
   > ```json
   > {
   >   "uri": "/*",
   >   "name": "111",
   >   "methods": [
   >     "GET"
   >   ],
   >   "host": "www.baidu.com",
   >   "plugins": {
   >     "traffic-split": {
   > 	"rules": [
   > 	  {
   > 	    "match": [
   > 		{
   > 		    "vars": [
   > 		            [
   > 		              "cookie_env",
   > 		              "==",
   > 		              "a"
   > 		            ]
   > 		          ]
   > 		        }
   > 		      ],
   > 		      "weighted_upstreams": [
   > 		        { ... }
   > 	       ]
   >             }
   > 	]
   >      }
   >   },
   >   "service_id": "430541345438827213",
   >   "status": 1
   > }
   > ```
   > 
   > When cookie_env=a, point to baidu.com on the Internet. If cookie_env is not a, then point to service_id internally
   
   let me experiment it. 🤔


-- 
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


[GitHub] [apisix] chyoong commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
chyoong commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308692741

   > @chyoong you see this issue can help you ? #8199
   
   I tried this method, but it still pointed to upstream_id, but I expected it to point to $host


-- 
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


[GitHub] [apisix] chyoong commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
chyoong commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308727380

   > @chyoong i give you an example
   > 
   > `curl http://127.0.0.1:9180/apisix/admin/routes/1 \ -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/index.html", "plugins": { "traffic-split": { "rules": [ { "match": [ { "vars": [ ["http_release","==","new_release"] ] } ], "weighted_upstreams": [ { "upstream": { "name": "upstream_A", "type": "roundrobin", "nodes": { "127.0.0.1:1981":10 } } } ] } ] } }, "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }' `
   
   
   
   
   Let me give you an example:
   
   ```json
   {
     "uri": "/*",
     "name": "111",
     "methods": [
       "GET"
     ],
     "host": "www.baidu.com",
     "plugins": {
       "traffic-split": {
   	"rules": [
   	  {
   	    "match": [
   		{
   		    "vars": [
   		            [
   		              "cookie_env",
   		              "==",
   		              "a"
   		            ]
   		          ]
   		        }
   		      ],
   		      "weighted_upstreams": [
   		        { ... }
   	       ]
               }
   	]
        }
     },
     "service_id": "430541345438827213",
     "status": 1
   }
   ```
   When cookie_env=a, point to baidu.com on the Internet. If cookie_env is not a, then point to service_id internally
   


-- 
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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308663773

   @chyoong Hi,why weighted_upstreams is nil ?


-- 
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


[GitHub] [apisix] ada012 closed issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by "ada012 (via GitHub)" <gi...@apache.org>.
ada012 closed issue #8290: help request: How to implement the "proxy_pass: https://$host" feature
URL: https://github.com/apache/apisix/issues/8290


-- 
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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308679616

   @chyoong   you see this issue can help you ? https://github.com/apache/apisix/issues/8199


-- 
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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1309977470

   > > 
   > 
   > @Hazel6869 Yes, your experiment is OK, but how is the pass $host configured? For example:
   > 
   > In the
   > 
   > ```
   > "nodes": {
   >     "www.baidu.com:80": 1
   > }
   > ```
   > 
   > is replaced by
   > 
   > ```
   > "nodes": {
   >     "$host:80": 1
   > }
   > ```
   > 
   > not work
   
   I am afraid this plugin can't support it


-- 
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


[GitHub] [apisix] chyoong commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
chyoong commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1308672949

   > @chyoong嗨,为什么 weighted_upstreams 是 nil ?
   @Hazel6869 
   upstream 'still doesn't take effect if we set' weighted_upstreams.upstream ', but that's not a problem. The question is how do we set 'proxy_pass https://$host' in traffic-split


-- 
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


[GitHub] [apisix] Hazel6869 commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
Hazel6869 commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1309720075

   @chyoong  Hi, I have experiment,  it has worked 
   
   `curl http://127.0.0.1:9080/apisix/admin/routes/1 \
   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
   {
       "uri": "/*",
       "plugins": {
           "traffic-split": {
               "rules": [
                   {
                       "match": [
                           {
                               "vars": [
                                   ["cookie_env","==","a"]
                               ]
                           }
                       ],
                       "weighted_upstreams": [
                           {
                               "upstream": {
                                   "name": "upstream-B",
                                   "type": "roundrobin",
                                    "pass_host": "node",
                                    "nodes": {
                                       "www.baidu.com:80": 1
                                       }
                               },
                               "weight": 3
                           }
                       ]
                   }
               ]
           }
       },
       "upstream": {
               "type": "roundrobin",
               "nodes": {
               "httpbin.org": 1
           }
       }
   }'
   
   
    curl -X GET http://127.0.0.1:9080 -v //visit httpbin
    curl -X GET http://127.0.0.1:9080 -H 'Cookie: env=a'  -v //visit baidu`


-- 
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


[GitHub] [apisix] chyoong commented on issue #8290: help request: How to implement the "proxy_pass: https://$host" feature

Posted by GitBox <gi...@apache.org>.
chyoong commented on issue #8290:
URL: https://github.com/apache/apisix/issues/8290#issuecomment-1309907055

   > 
   
   
   @Hazel6869  Yes, your experiment is OK, but how is the pass $host configured? For example:
   
   In the
   ```
   "nodes": {
       "www.baidu.com:80": 1
   }
   ```
   is replaced by 
   
   ```
   "nodes": {
       "$host:80": 1
   }
   ```
   not work


-- 
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