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 2021/10/14 06:51:58 UTC

[GitHub] [apisix] siaron opened a new issue #5233: request help: no host allowed while connecting to upstream

siaron opened a new issue #5233:
URL: https://github.com/apache/apisix/issues/5233


   ### Issue description
   
   从nacos上发现服务.
   - nacos上的服务ip为主机名`uaa-service`, 一个为ip
   - 当负载均衡运行时报 `failed to set server peer [uaa-service:20101] err: no host allowed while connecting to upstream`
   
   ### Environment
   
   - apisix version (cmd: `apisix version`):
   - 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] tzssangglass commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > i have resolved this issue related to eureka. how can i contributor?
   
   Can you start with a brief chat about how it was solved?


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   hi @drrrMikado, the cause and the solution of this problem are provided above. Since it is your own plugin, there is nothing I can do about 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] siaron edited a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   > use `dig uaa-service` and show the result, and proveide the environment info
   
   ```
   apisix version (cmd: apisix version): 2.10.0
   OS (cmd: uname -a): macos
   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):
   ```
   {
   "version": "2.10.0",
   "hostname": "localhost",
   "etcd_version": "3.5.0",
   "up_time": 48,
   "id": "c1141ba7-70c4-41a9-8d9d-c54c70ac2912",
   "boot_time": 1634215727,
   "last_report_time": 1634215727
   }
   ```
   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):
   ```
   
   ### 复现方式
   - discovery config
   ```
   discovery:                       # service discovery center
   #  dns:
   #    servers:
   #      - "127.0.0.1:8600"         # use the real address of your dns server
    nacos:
     host:                        # it's possible to define multiple eureka hosts addresses of the same eureka cluster.
       - "http://nacos:nacos@127.0.0.1:8848"
     prefix: "/nacos/v1/"
     fetch_interval: 3    # default 30 sec
     weight: 10           # default 100
     timeout:
       connect: 2000       # default 2000 ms
       send: 2000          # default 2000 ms
       read: 5000          # default 5000 ms
   ```
   - nacos注册服务为
   ![image](https://user-images.githubusercontent.com/13701232/137320809-ac9294d9-6b43-4072-bc69-61601983eb8f.png)
   - host 配置
   ```
   localhost:apisix-2.10.0 xxx$ cat /etc/hosts
   127.0.0.1 uaa-service uaa-service-host
   ```
   - 路由配置
   ```
   {
     "uri": "/uaa/*",
     "name": "uaa服务",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "upstream_id": "376959049259811901",
     "status": 1
   }
   ```
   - 上游服务
   ```
   {
     "timeout": {
       "connect": 6,
       "send": 6,
       "read": 6
     },
     "type": "roundrobin",
     "scheme": "http",
     "discovery_type": "nacos",
     "pass_host": "pass",
     "name": "uaa2",
     "service_name": "uaa-service",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1000,
       "size": 320
     }
   }
   ```
   - 调用服务
   ![image](https://user-images.githubusercontent.com/13701232/137321223-40b1090d-50c0-4317-9a18-2258688ec8a1.png)
   
   - 测试
   ```
   localhost:apisix-2.10.0 xielongwang$ ping uaa-service-host
   PING uaa-service (127.0.0.1): 56 data bytes
   64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.147 ms
   64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.249 ms
   64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.269 ms
   64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.109 ms
   64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.232 ms
   64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.258 ms
   64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.371 ms
   64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.239 ms
   ^C
   --- uaa-service ping statistics ---
   8 packets transmitted, 8 packets received, 0.0% packet loss
   round-trip min/avg/max/stddev = 0.109/0.234/0.371/0.074 ms
   localhost:apisix-2.10.0 xielongwang$ dig uaa-service-host
   
   ; <<>> DiG 9.10.6 <<>> uaa-service-host
   ;; global options: +cmd
   ;; Got answer:
   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55283
   ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
   
   ;; QUESTION SECTION:
   ;uaa-service-host.		IN	A
   
   ;; Query time: 86 msec
   ;; SERVER: 192.168.31.1#53(192.168.31.1)
   ;; WHEN: Thu Oct 14 20:54:55 CST 2021
   ;; MSG SIZE  rcvd: 34
   
   localhost:apisix-2.10.0 xielongwang$
   ```
   - 日志打印
   ```
   2021/10/14 20:49:04 [error] 71097#853898: *2184 [lua] balancer.lua:353: run(): failed to set server peer [uaa-service-host:30101] err: no host allowed while connecting to upstream, client: 127.0.0.1, server: _, request: "GET /uaa/test/hello HTTP/1.1", host: "127.0.0.1:9080"
   ```
   - 相关 issues
   https://github.com/openresty/lua-resty-core/issues/45
   


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   > > Did you write the host and ip mappings in /etc/hosts beforehand?
   > 
   > yeah, i think this is General Situation
   > 
   > > I have a suggestion for enhancing nacos/eureka
   > > determine whether the host is a domain or an ip
   > 
   > 1. determine whether the host is a domain or an ip
   > 2. if it's a domain, resolve the domain to an ip, overriding the host
   > 
   > nice~ so. i modify the code resolver .parse_domain that can get ip from ' host to ip ' mapping in high priority then use dns_parse ?
   
   It seems that this is a more generic demands that we can use the `/etc/hosts` to change the DNS resolving.


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   > nice~ so. i modify the code resolver .parse_domain that can get ip from ' host to ip ' mapping in high priority then use dns_parse ?
   
   just try


-- 
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] siaron edited a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   > use `dig uaa-service` and show the result, and proveide the environment info
   
   ```
   apisix version (cmd: apisix version): 2.10.0
   OS (cmd: uname -a): macos
   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):
   ```
   {
   "version": "2.10.0",
   "hostname": "localhost",
   "etcd_version": "3.5.0",
   "up_time": 48,
   "id": "c1141ba7-70c4-41a9-8d9d-c54c70ac2912",
   "boot_time": 1634215727,
   "last_report_time": 1634215727
   }
   ```
   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):
   ```
   
   ### 复现方式
   - discovery config
   ```
   discovery:                       # service discovery center
   #  dns:
   #    servers:
   #      - "127.0.0.1:8600"         # use the real address of your dns server
    nacos:
     host:                        # it's possible to define multiple eureka hosts addresses of the same eureka cluster.
       - "http://nacos:nacos@127.0.0.1:8848"
     prefix: "/nacos/v1/"
     fetch_interval: 3    # default 30 sec
     weight: 10           # default 100
     timeout:
       connect: 2000       # default 2000 ms
       send: 2000          # default 2000 ms
       read: 5000          # default 5000 ms
   ```
   - nacos注册服务为
   ![image](https://user-images.githubusercontent.com/13701232/137320809-ac9294d9-6b43-4072-bc69-61601983eb8f.png)
   - host 配置
   ```
   localhost:apisix-2.10.0 xxx$ cat /etc/hosts
   127.0.0.1 uaa-service uaa-service-host
   ```
   - 路由配置
   ```
   {
     "uri": "/uaa/*",
     "name": "uaa服务",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "upstream_id": "376959049259811901",
     "status": 1
   }
   ```
   - 上游服务
   ```
   {
     "timeout": {
       "connect": 6,
       "send": 6,
       "read": 6
     },
     "type": "roundrobin",
     "scheme": "http",
     "discovery_type": "nacos",
     "pass_host": "pass",
     "name": "uaa2",
     "service_name": "uaa-service",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1000,
       "size": 320
     }
   }
   ```
   - 调用服务
   ![image](https://user-images.githubusercontent.com/13701232/137321223-40b1090d-50c0-4317-9a18-2258688ec8a1.png)
   
   - 测试
   ```
   localhost:apisix-2.10.0 xielongwang$ ping uaa-service-host
   PING uaa-service (127.0.0.1): 56 data bytes
   64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.147 ms
   64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.249 ms
   64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.269 ms
   64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.109 ms
   64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.232 ms
   64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.258 ms
   64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.371 ms
   64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.239 ms
   ^C
   --- uaa-service ping statistics ---
   8 packets transmitted, 8 packets received, 0.0% packet loss
   round-trip min/avg/max/stddev = 0.109/0.234/0.371/0.074 ms
   localhost:apisix-2.10.0 xielongwang$ dig uaa-service-host
   
   ; <<>> DiG 9.10.6 <<>> uaa-service-host
   ;; global options: +cmd
   ;; Got answer:
   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55283
   ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
   
   ;; QUESTION SECTION:
   ;uaa-service-host.		IN	A
   
   ;; Query time: 86 msec
   ;; SERVER: 192.168.31.1#53(192.168.31.1)
   ;; WHEN: Thu Oct 14 20:54:55 CST 2021
   ;; MSG SIZE  rcvd: 34
   
   localhost:apisix-2.10.0 xielongwang$
   ```
   - 日志打印
   ```
   2021/10/14 20:49:04 [error] 71097#853898: *2184 [lua] balancer.lua:353: run(): failed to set server peer [uaa-service-host:30101] err: no host allowed while connecting to upstream, client: 127.0.0.1, server: _, request: "GET /uaa/test/hello HTTP/1.1", host: "127.0.0.1:9080"
   ```
   - 相关 issues
     - https://github.com/openresty/lua-resty-core/issues/45
     - https://github.com/Kong/kong/issues/4786


-- 
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] siaron edited a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   > ### Issue description
   > 从nacos上发现服务.
   > 
   > * nacos上的服务ip为主机名`uaa-service`, 一个为ip
   > * 当负载均衡运行时报 `failed to set server peer [uaa-service:20101] err: no host allowed while connecting to upstream`
   > 
   > ### Environment
   > * apisix version (cmd: `apisix version`):
   > * 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`):
   
   ![image](https://user-images.githubusercontent.com/13701232/137266499-8e8e5a07-7d1f-44b3-96b9-f262289f8d87.png)
   如果使用上游类型是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] TenYearsIn commented on issue #5233: request help: no host allowed while connecting to upstream

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


   i have resolved this issue related to eureka. how can i contributor?


-- 
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 edited a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   > I parse the file '/etc/hosts' with RegExp in the initial phase
   
   Did you write the host and ip mappings in `/etc/hosts` beforehand?
   
   > So I can get 'hosts to ip' mapping . then I modify eureka code
   > that get ip (the code is line 132 in /apisix/discovery/eureka/init.lua ), use mapping relations to get ip in high priority , if not, I use the eureka service ip oneself .
   
   I have a suggestion for enhancing nacos/eureka
   
   1. determine whether the host is a domain or an ip
   2. if it's a domain, resolve the domain to an ip, overriding the host
   
   ref: https://github.com/apache/apisix/blob/719c5388143d73cc1424d0a03ec51584a60e243e/apisix/init.lua#L166-L188


-- 
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] nic-6443 commented on issue #5233: request help: no host allowed while connecting to upstream

Posted by GitBox <gi...@apache.org>.
nic-6443 commented on issue #5233:
URL: https://github.com/apache/apisix/issues/5233#issuecomment-943359455


   At present, the APISIX nacos plug-in does not perform dns resolution on the back-end host it gets ([code location](https://github.com/apache/apisix/blob/master/apisix/discovery/nacos.lua#L303-L330)), so if the domain name is configured in nacos, it will be directly used as the parameter of `balancer.set_current_peer`, which will lead to `no host allowed While connecting to upstream` error. 
   The configuration node on the Dashboard page will first do dns query and then give `balancer.set_current_peer`, so it can work. [code location](https://github.com/apache/apisix/blob/master/apisix/init.lua#L166-L166)
   So the error you encountered is in line with expectations, we can further consider whether service discovery should support configuration in the form of domain names.
   


-- 
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] TenYearsIn commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > > i have resolved this issue related to eureka. how can i contributor?
   > 
   > Can you start with a brief chat about how it was solved?
   
   I parse the file '/etc/hosts' with RegExp in the initial phase,So I can get  'hosts to ip'  mapping .  then I modify eureka code 
    that  get ip (the code is line 132 in /apisix/discovery/eureka/init.lua ), use mapping relations to get ip in high priority , if not,  I use the eureka service ip oneself .


-- 
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] TenYearsIn commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > Did you write the host and ip mappings in /etc/hosts beforehand?
   
   yeah,  i think this is General Situation
   
   > I have a suggestion for enhancing nacos/eureka
   determine whether the host is a domain or an ip
   1. determine whether the host is a domain or an ip
   2. if it's a domain, resolve the domain to an ip, overriding the host
   
   nice~  so. i modify the code resolver .parse_domain that can get ip from ' host to ip ' mapping  in high priority then use dns_parse ? 


-- 
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] siaron commented on issue #5233: request help: no host allowed while connecting to upstream

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


   配置了host了. 能ping通的
   ```
   localhost:~ xxx$ ping uaa-service
   PING uaa-service (127.0.0.1): 56 data bytes
   64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.084 ms
   64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.293 ms
   64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.128 ms
   ^C
   --- uaa-service ping statistics ---
   3 packets transmitted, 3 packets received, 0.0% packet loss
   round-trip min/avg/max/stddev = 0.084/0.168/0.293/0.090 ms
   ```


-- 
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] biubiue commented on issue #5233: request help: no host allowed while connecting to upstream

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


   mark


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   > I parse the file '/etc/hosts' with RegExp in the initial phase
   
   Did you write the host and ip mappings in `/etc/hosts` beforehand?
   
   > So I can get 'hosts to ip' mapping . then I modify eureka code
   > that get ip (the code is line 132 in /apisix/discovery/eureka/init.lua ), use mapping relations to get ip in high priority , if not, I use the eureka service ip oneself .
   
   1. determine whether the host is a domain or an ip
   2. if it's a domain, resolve the domain to an ip, overriding the host
   
   ref: https://github.com/apache/apisix/blob/719c5388143d73cc1424d0a03ec51584a60e243e/apisix/init.lua#L166-L188


-- 
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] siaron commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > ### Issue description
   > 从nacos上发现服务.
   > 
   > * nacos上的服务ip为主机名`uaa-service`, 一个为ip
   > * 当负载均衡运行时报 `failed to set server peer [uaa-service:20101] err: no host allowed while connecting to upstream`
   > 
   > ### Environment
   > * apisix version (cmd: `apisix version`):
   > * 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`):
   
   ![image](https://user-images.githubusercontent.com/13701232/137266499-8e8e5a07-7d1f-44b3-96b9-f262289f8d87.png)
   这里如果是主机名是没有问题的. 


-- 
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] TenYearsIn removed a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   > > i have resolved this issue related to eureka. how can i contributor?
   > 
   > Can you start with a brief chat about how it was solved?
   
   I parse the file '/etc/hosts' with RegExp in the initial phase,So I can get  'hosts to ip'  mapping .  then I modify eureka code 
    that  get ip (the code is line 132 in /apisix/discovery/eureka/init.lua ), use mapping relations to get ip in high priority , if not,  I use the eureka service ip oneself .


-- 
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] drrrMikado commented on issue #5233: request help: no host allowed while connecting to upstream

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


   I get same error in custom plugin when rewrite upstream.
   Upstream data:
   ```json
   {
       "id": "ups-sys1-abcd",
       "create_time": 1643165083,
       "update_time": 1643190928,
       "nodes": [
           {
               "host": "example.com",
               "port": 80,
               "weight": 1
           }
       ],
       "type": "roundrobin",
       "hash_on": "vars",
       "scheme": "http",
       "pass_host": "pass",
       "name": "ups-sys1-abcd"
   }
   ```
   Route:
   ```json
   {
       "id": "1",
       "create_time": 1643186095,
       "update_time": 1643187397,
       "uri": "/get",
       "name": "",
       "methods": [
           "GET"
       ],
       "host": "sys1.com",
       "plugins": {
           "custom-plugin": {}
       },
       "upstream": {
           "nodes": [
               {
                   "host": "httpbin.org",
                   "port": 80,
                   "weight": 1
               }
           ],
           "type": "roundrobin",
           "hash_on": "vars",
           "scheme": "http",
           "pass_host": "pass"
       },
       "status": 1
   }
   ```
   Custom plugin code:
   ```lua
   function _M.rewrite(conf, ctx)
       -- rewrite by request header
       -- get upstream info
       local upstreams = core.config.fetch_created_obj("/upstreams")
       if not upstreams then
           return core.response.exit(502)
       end
       -- new upstream id by system name and tag
       local upstream_id = "ups-sys1-abcd"
       local ups_info = upstreams:get(tostring(upstream_id))
       if not ups_info then
           return
       end
       ups_info = ups_info.value
       upstream.set(ctx, ups_info.name, ctx.conf_version, ups_info)
   end
   ```
   error log:
   ```
   apisix            | 2022/01/26 09:11:48 [error] 48#48: *456684 [lua] balancer.lua:353: run(): failed to set server peer [example.com:80] err: no host allowed while connecting to upstream, client: 172.18.0.1, server: _, request: "GET /get HTTP/1.1", host: "sys1.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] drrrMikado commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > hi @drrrMikado, the cause and the solution of this problem are provided above. Since it is your own plugin, there is nothing I can do about it.
   
   Ok, Thanks.


-- 
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] shuaijinchao commented on issue #5233: request help: no host allowed while connecting to upstream

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


   Whether the hostname of `uaa-service` has been configured with DNS resolution on the APISIX node, you can test it on the APISIX node `ping uaa-service`


-- 
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] siaron commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > use `dig uaa-service` and show the result, and proveide the environment info
   
   ```
   apisix version (cmd: apisix version): 2.10.0
   OS (cmd: uname -a): macos
   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):
   ```
   {
   "version": "2.10.0",
   "hostname": "localhost",
   "etcd_version": "3.5.0",
   "up_time": 48,
   "id": "c1141ba7-70c4-41a9-8d9d-c54c70ac2912",
   "boot_time": 1634215727,
   "last_report_time": 1634215727
   }
   ```
   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):
   ```
   
   ### 复现方式
   - discovery config
   ```
   discovery:                       # service discovery center
   #  dns:
   #    servers:
   #      - "127.0.0.1:8600"         # use the real address of your dns server
    nacos:
     host:                        # it's possible to define multiple eureka hosts addresses of the same eureka cluster.
       - "http://nacos:nacos@127.0.0.1:8848"
     prefix: "/nacos/v1/"
     fetch_interval: 3    # default 30 sec
     weight: 10           # default 100
     timeout:
       connect: 2000       # default 2000 ms
       send: 2000          # default 2000 ms
       read: 5000          # default 5000 ms
   ```
   - nacos注册服务为
   ![image](https://user-images.githubusercontent.com/13701232/137320809-ac9294d9-6b43-4072-bc69-61601983eb8f.png)
   - host 配置
   ```
   localhost:apisix-2.10.0 xxx$ cat /etc/hosts
   127.0.0.1 uaa-service uaa-service-host
   ```
   - 路由配置
   ```
   {
     "uri": "/uaa/*",
     "name": "uaa服务",
     "methods": [
       "GET",
       "POST",
       "PUT",
       "DELETE",
       "PATCH",
       "HEAD",
       "OPTIONS",
       "CONNECT",
       "TRACE"
     ],
     "upstream_id": "376959049259811901",
     "status": 1
   }
   ```
   - 上游服务
   ```
   {
     "timeout": {
       "connect": 6,
       "send": 6,
       "read": 6
     },
     "type": "roundrobin",
     "scheme": "http",
     "discovery_type": "nacos",
     "pass_host": "pass",
     "name": "uaa2",
     "service_name": "uaa-service",
     "keepalive_pool": {
       "idle_timeout": 60,
       "requests": 1000,
       "size": 320
     }
   }
   ```
   - 调用服务
   ![image](https://user-images.githubusercontent.com/13701232/137321223-40b1090d-50c0-4317-9a18-2258688ec8a1.png)
   
   - 测试
   ```
   localhost:apisix-2.10.0 xielongwang$ ping uaa-service-host
   PING uaa-service (127.0.0.1): 56 data bytes
   64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.147 ms
   64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.249 ms
   64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.269 ms
   64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.109 ms
   64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.232 ms
   64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.258 ms
   64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.371 ms
   64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.239 ms
   ^C
   --- uaa-service ping statistics ---
   8 packets transmitted, 8 packets received, 0.0% packet loss
   round-trip min/avg/max/stddev = 0.109/0.234/0.371/0.074 ms
   localhost:apisix-2.10.0 xielongwang$ dig uaa-service-host
   
   ; <<>> DiG 9.10.6 <<>> uaa-service-host
   ;; global options: +cmd
   ;; Got answer:
   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55283
   ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
   
   ;; QUESTION SECTION:
   ;uaa-service-host.		IN	A
   
   ;; Query time: 86 msec
   ;; SERVER: 192.168.31.1#53(192.168.31.1)
   ;; WHEN: Thu Oct 14 20:54:55 CST 2021
   ;; MSG SIZE  rcvd: 34
   
   localhost:apisix-2.10.0 xielongwang$
   ```


-- 
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] TenYearsIn commented on issue #5233: request help: no host allowed while connecting to upstream

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


   > > i have resolved this issue related to eureka. how can i contributor?
   > 
   > Can you start with a brief chat about how it was solved?
   
   I parse the file '/etc/hosts' with RegExp in the initial phase,So I can get  'hosts to ip'  mapping .  then I modify eureka code 
    that  get ip (the code is line 132 in /apisix/discovery/eureka/init.lua ), use mapping relations to get ip in high priority , if not,  I use the eureka service ip oneself .


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   use `dig uaa-service` and show the result, and proveide the environment info


-- 
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] biubiue edited a comment on issue #5233: request help: no host allowed while connecting to upstream

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


   mark,same problem, register domain as  nacos ip.


-- 
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 #5233: request help: no host allowed while connecting to upstream

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


   > It seems that this is a more generic demands that we can use the `/etc/hosts` to change the DNS resolving.
   
   Our dns resolution process also takes resolution information from /etc/hosts. So the key point of my suggestion is to use the existing dns resolution method, not just /etc/hosts, to resolve the 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