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/02/23 15:31:30 UTC

[GitHub] [apisix] tiyorn opened a new issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

tiyorn opened a new issue #6430:
URL: https://github.com/apache/apisix/issues/6430


   ### Issue description
   
    Why in the case of upstream multiple nodes, set `pass_node = node`, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080,which is the address of apisix itself.
   
   route config:
   ```
   {
     "uris": [
       "/blog/*"
     ],
     "name": "",
     "plugins": {
       "proxy-rewrite": {
         "regex_uri": [
           "/blog/(.*)",
           "/$1"
         ],
         "scheme": "http"
       }
     },
     "upstream": {
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 1
         }
       ],
       "type": "roundrobin",
       "hash_on": "vars",
       "scheme": "http",
       "pass_host": "node"
     },
     "status": 1
   }
   ```
   
   When forwarding the request, the host header will be set to `http://127.0.0.1:9080`,why?
   `pass_host = node` only support domain name scene?why can't just use ip directly?
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):2.11.0
   - OS (cmd: `uname -a`):
   - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   - apisix-dashboard version, if have:
   - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
   - luarocks version, if the issue is about installation (cmd: `luarocks --version`):
   


-- 
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] tiyorn edited a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
tiyorn edited a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1050478434


   > > it does not take effect. It only takes effect when nodes.host is domain name.
   > 
   > I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?
   
   set `pass_host == node`
   while set nodes:
   ```
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header is unexpected: `http://127.0.0.1:9080`,  expected: `https://192.168.0.1` or `https://192.168.0.2`
   
   while set nodes:
   ```
       "nodes": [
         {
           "host": "ly.sylc1.com",
           "port": 80,
           "weight": 1
         },
         {
           "host": "ly.sylc2.com",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header is expected: `http://ly.sylc1.com` or `http://ly.sylc2.com`.


-- 
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] tokers commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > When forwarding the request, the host header will be set to http://127.0.0.1:9080,why?
   > pass_host = node only support domain name scene?why can't just use ip directly?
   
   When the value of `pass_host` is `node`, the HTTP Host header will set according to the domain/ip of this node.
   
   


-- 
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] liangliang4ward commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > > > it does not take effect. It only takes effect when nodes.host is domain name.
   > > 
   > > 
   > > I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?
   > 
   > set `pass_host == node` while set nodes:
   > 
   > ```
   >     "nodes": [
   >       {
   >         "host": "192.168.0.1",
   >         "port": 80,
   >         "weight": 1
   >       },
   >       {
   >         "host": "192.168.0.2",
   >         "port": 80,
   >         "weight": 1
   >       }
   >     ],
   > ```
   > 
   > the actual Host header to upstream is unexpected: `http://127.0.0.1:9080`, expected: `https://192.168.0.1` or `https://192.168.0.2`
   > 
   > while set nodes:
   > 
   > ```
   >     "nodes": [
   >       {
   >         "host": "ly.sylc1.com",
   >         "port": 80,
   >         "weight": 1
   >       },
   >       {
   >         "host": "ly.sylc2.com",
   >         "port": 80,
   >         "weight": 1
   >       }
   >     ],
   > ```
   > 
   > the actual Host header to upstream is expected: `http://ly.sylc1.com` or `http://ly.sylc2.com`.
   
   how did you check


-- 
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] tzssangglass commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > it does not take effect. It only takes effect when nodes.host is domain name.
   
   I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?


-- 
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] tiyorn edited a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
tiyorn edited a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1050478434


   > > it does not take effect. It only takes effect when nodes.host is domain name.
   > 
   > I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?
   
   set `pass_host == node`
   while set nodes:
   ```
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header is unexpected: `http://127.0.0.1:9080`,  expected: `https://192.168.0.1` or `https://192.168.0.2`
   
   while set nodes:
       "nodes": [
         {
           "host": "ly.sylc1.com",
           "port": 80,
           "weight": 1
         },
         {
           "host": "ly.sylc2.com",
           "port": 80,
           "weight": 1
         }
       ],
   the actual Host header is expected: `http://ly.sylc1.com` or `http://ly.sylc2.com`.


-- 
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] liangliang4ward removed a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
liangliang4ward removed a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1049403491


   I thount when pass_host=="node" upstream node only support one.
   
   https://github.com/apache/apisix/blob/749094bb55421f5b715af18e376c373603bf5d62/apisix/upstream.lua#L424
   
   ```lua
       if conf.pass_host == "node" and conf.nodes and
           not balancer.recreate_request and core.table.nkeys(conf.nodes) ~= 1
       then
           return false, "only support single node for `node` mode currently"
       end
   ```


-- 
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] tzssangglass commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > I know, but when multiple upstream addresses are set to ip instead of domain names, it will not take effect.
   
   Not really understood.
   
   Are you saying that when there are multiple nodes in the upstream, the Host header sent to the upstream is not the `host` configured in each node?


-- 
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] tiyorn edited a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
tiyorn edited a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1050478434


   > > it does not take effect. It only takes effect when nodes.host is domain name.
   > 
   > I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?
   
   set `pass_host == node`
   while set nodes:
   ```
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header to upstream is unexpected: `http://127.0.0.1:9080`,  expected: `https://192.168.0.1` or `https://192.168.0.2`
   
   while set nodes:
   ```
       "nodes": [
         {
           "host": "ly.sylc1.com",
           "port": 80,
           "weight": 1
         },
         {
           "host": "ly.sylc2.com",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header to upstream is expected: `http://ly.sylc1.com` or `http://ly.sylc2.com`.


-- 
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] tiyorn commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_host = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > > it does not take effect. It only takes effect when nodes.host is domain name.
   > 
   > I don't quite understand what you mean by not taking effect. What do you expect set `pass_host == node` to be, and what is the Host header that APISIX proxies to upstream? In fact, what is the Host header that you get from the APISIX proxy to the upstream?
   
   set `pass_host == node`
   while set nodes:
   ```
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 1
         }
       ],
   ```
   the actual Host header is unexpected: `http://127.0.0.1:9080`,  expected: `https://192.168.0.1` or `https://192.168.0.2`
   
   while set nodes:
       "nodes": [
         {
           "host": "ly.sylc1.com",
           "port": 80,
           "weight": 1
         },
         {
           "host": "ly.sylc2.com",
           "port": 80,
           "weight": 1
         }
       ],
   the actual Host header is expected: `http://ly.sylc1.com` or 'http://ly.sylc2.com'.


-- 
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] liangliang4ward commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   I thount when pass_host=="node" upstream node only support one.
   
   https://github.com/apache/apisix/blob/749094bb55421f5b715af18e376c373603bf5d62/apisix/upstream.lua#L424


-- 
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] tiyorn commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > ented [13分钟前](#issuecomment-1049406864)
   
   
   
   > > When forwarding the request, the host header will be set to [http://127.0.0.1:9080,why?](http://127.0.0.1:9080%EF%BC%8Cwhy%EF%BC%9F)
   > > pass_host = node only support domain name scene?why can't just use ip directly?
   > 
   > When the value of `pass_host` is `node`, the HTTP Host header will set according to the domain/ip of this node.
   
   I know, but when multiple upstream addresses are set to ip instead of domain names, it will not take effect.
   


-- 
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] liangliang4ward edited a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
liangliang4ward edited a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1049403491


   I thount when pass_host=="node" upstream node only support one.
   
   https://github.com/apache/apisix/blob/749094bb55421f5b715af18e376c373603bf5d62/apisix/upstream.lua#L424
   
   ```lua
       if conf.pass_host == "node" and conf.nodes and
           not balancer.recreate_request and core.table.nkeys(conf.nodes) ~= 1
       then
           return false, "only support single node for `node` mode currently"
       end
   ```


-- 
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] tiyorn commented on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

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


   > 
   
   
   
   > > I know, but when multiple upstream addresses are set to ip instead of domain names, it will not take effect.
   > 
   > Not really understood.
   > 
   > Are you saying that when there are multiple nodes in the upstream, the Host header sent to the upstream is not the `host` configured in each node?
   
   Yes, set `pass_host == node`, when nodes.host is directly ip, it does not take effect. It only takes effect when nodes.host is domain name.


-- 
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] tiyorn edited a comment on issue #6430: request help: Why in the case of upstream multiple nodes, set pass_node = node, nodes can only use domain name, not ip directly, otherwise host will be set to 127.0.0.1:9080

Posted by GitBox <gi...@apache.org>.
tiyorn edited a comment on issue #6430:
URL: https://github.com/apache/apisix/issues/6430#issuecomment-1049414046


   > ented [13分钟前](#issuecomment-1049406864)
   
   
   
   > > When forwarding the request, the host header will be set to [http://127.0.0.1:9080,why?](http://127.0.0.1:9080%EF%BC%8Cwhy%EF%BC%9F)
   > > pass_host = node only support domain name scene?why can't just use ip directly?
   > 
   > When the value of `pass_host` is `node`, the HTTP Host header will set according to the domain/ip of this node.
   
   I know, but when multiple upstream addresses are set to ip instead of domain names, it will not take effect.
   
   upstream.nodes:
   ```
       "nodes": [
         {
           "host": "192.168.0.1",
           "port": 80,
           "weight": 1
         },
         {
           "host": "192.168.0.2",
           "port": 80,
           "weight": 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