nacos-group / r-nacos

Nacos server re-implemented in Rust.
https://r-nacos.github.io/docs/
Apache License 2.0
898 stars 97 forks source link

Docker 部署 不能访问 外网 ip:10848/rancos #158

Open Avey777 opened 2 hours ago

Avey777 commented 2 hours ago
# 集群部署样例,数据目录: ./data
version: '3.8'

services:
  nacos:
    image: qingpan/rnacos:stable
    container_name: rnacos
    ports:
      - "8848:8848"
      - "9848:9848"
      - "10848:10848"
    volumes:
      - ./data:/io:rw
    environment:
      - RNACOS_INIT_ADMIN_USERNAME=admin
      - RNACOS_INIT_ADMIN_PASSWORD=admin
      - RNACOS_HTTP_PORT=8848
      - RNACOS_RAFT_AUTO_INIT=true
      - RNACOS_HTTP_CONSOLE_PORT=10848
      - RNACOS_ENABLE_NO_AUTH_CONSOLE=false
    restart: always

http://192.210.197.70:10848/rnacos

image

heqingpan commented 2 hours ago

可能服务防火墙没有开放对应的端口号。

你可以在docker宿主机本地用curl 请求试试,如果通过127.0.0.1能访问,那就可以确认是防火墙配置问题。

Avey777 commented 2 hours ago

可能服务防火墙没有开放对应的端口号。

你可以在docker宿主机本地用curl 请求试试,如果通过127.0.0.1能访问,那就可以确认是防火墙配置问题。

root@racknerd:/opt/r-nacos# curl 127.0.0.1:10848
root@racknerd:/opt/r-nacos# curl 127.0.0.1:10848/rnacos
root@racknerd:/opt/r-nacos# 

image

没有开启防火墙


[2024-11-01 09:21:50.463273 +00:00 INFO  rnacos] http server addr:0.0.0.0:8848
[2024-11-01 09:21:50.463342 +00:00 INFO  rnacos] grpc server addr:0.0.0.0:9848
[2024-11-01 09:21:50.464461 +00:00 INFO  rnacos] new console server http addr:0.0.0.0:10848
rnacos started
[2024-11-01 09:21:50.464964 +00:00 INFO  actix_server::builder] starting 2 workers
[2024-11-01 09:21:50.465107 +00:00 INFO  actix_server::server] Actix runtime found; starting in Actix runtime
[2024-11-01 09:21:50.465225 +00:00 INFO  actix_server::server] starting service: "actix-web-service-0.0.0.0:8848", workers: 2, listening on: 0.0.0.0:8848
[2024-11-01 09:21:50.465540 +00:00 INFO  actix_server::builder] starting 2 workers
[2024-11-01 09:21:50.466238 +00:00 INFO  actix_server::server] Actix runtime found; starting in Actix runtime
[2024-11-01 09:21:50.466274 +00:00 INFO  actix_server::server] starting service: "actix-web-service-0.0.0.0:10848", workers: 2, listening on: 0.0.0.0:10848
[2024-11-01 09:21:50.472907 +00:00 INFO  rnacos::naming::cluster::node_manage] InnerNodeManage UpdateNodes,size:1
[2024-11-01 09:21:50.473050 +00:00 INFO  rnacos::naming::cluster::node_manage] InnerNodeManage UpdateNodes,size:1
[2024-11-01 09:21:50.474072 +00:00 INFO  rnacos::raft::filestore::raftapply] raft data load finished.
[2024-11-01 09:21:50.474551 +00:00 INFO  rnacos::namespace] delay_init_from_old_value
[2024-11-01 09:21:50.474677 +00:00 INFO  rnacos::raft::filestore::core] get_initial_state from index_manager,LogIndexInfo { index: 6, term: 1 },MembershipConfig { members: {1}, members_after_consensus: None }
[2024-11-01 09:21:50.474788 +00:00 INFO  rnacos::raft::filestore::core] get_initial_state from index_manager,LogIndexInfo { index: 6, term: 1 },MembershipConfig { members: {1}, members_after_consensus: None }
[2024-11-01 09:21:55.476331 +00:00 INFO  rnacos::namespace] namespace InitFromOldValue done

开启 8848 旧的管理后台是可以的,但是 10848 的还是之前的问题 image

heqingpan commented 1 hour ago

那有点奇怪,r-nacos容器暴露出的几个端口应该是平等的;8848端口网络能通,而10848端口不能通。

建议对比检查一下端口的配置,比如可以把容器10848暴露出的端口换成8848看看是否能通。

另外上面的curl 可以加 -i参数确认返回的内容。

Avey777 commented 1 hour ago
version: '3.8'

services:
  nacos:
    image: qingpan/rnacos:stable
    container_name: rnacos
    ports:
      - "10848:8848"
      - "9848:9848"
      - "8848:10848"
    volumes:
      - ./data:/io:rw
    environment:
      - RNACOS_INIT_ADMIN_USERNAME=admin
      - RNACOS_INIT_ADMIN_PASSWORD=admin
      - RNACOS_HTTP_PORT=8848
      - RNACOS_RAFT_AUTO_INIT=true
      - RNACOS_HTTP_CONSOLE_PORT=10848
      - RNACOS_ENABLE_NO_AUTH_CONSOLE=true
    restart: always

这样配置的

root@racknerd:/opt/r-nacos# curl -i 127.0.0.1:10848
HTTP/1.1 200 OK
content-length: 477
content-type: text/html
date: Fri, 01 Nov 2024 10:21:09 GMT

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/rnacos/server.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>r-nacos console</title>
    <script type="module" crossorigin src="/rnacos/assets/index-e8edb0c5.js"></script>
    <link rel="stylesheet" href="/rnacos/assets/index-5beca6f5.css">
  </head>
  <body>
    <div id="app"></div>

  </body>
</html>
root@racknerd:/opt/r-nacos# curl -i 127.0.0.1:8848
HTTP/1.1 302 Found
content-length: 0
location: /rnacos/p/login?redirect_url=%2F
date: Fri, 01 Nov 2024 10:21:23 GMT

root@racknerd:/opt/r-nacos# 

http://192.210.197.70:8848/rnacos image

http://192.210.197.70:10848/rnacos image

这样也可以使用了,就是感觉怪怪的

heqingpan commented 1 hour ago

那就基本可以确认r-nacos提供的端口功能没有问题,是宿主机器10848端口不能被浏览器访问。再仔细检查一下网络10848端口的配置和8848有什么区别。

Avey777 commented 1 hour ago

那就基本可以确认r-nacos提供的端口功能没有问题,是宿主机器10848端口不能被浏览器访问。再仔细检查一下网络10848端口的配置和8848有什么区别。

可以用就好了,这个不想深究。

heqingpan commented 58 minutes ago

这个用控制台是没有问题,但使用程序访问时可能会有问题。r-nacos的8848端口与9848端口有个隐含的限制是它们的端口需要间隔1000。