AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-582429

mdx0111's questions

Martin Hope
mdx0111
Asked: 2020-07-09 22:13:13 +0800 CST

haproxy 负载均衡器无法访问 Podman rootful 容器

  • 2

我在 podman 中创建了两个网络,“后端”和“前端”。

NAME      VERSION  PLUGINS
podman    0.4.0    bridge,portmap,firewall,tuning
backend   0.4.0    bridge,portmap,firewall,dnsname
frontend  0.4.0    bridge,portmap,firewall,dnsname

我有一个使用以下命令在“后端”网络中运行的 MS Sql Server 容器:

podman run -d -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=TestS01Pass' --name mssqlserver -v sqlvolume:/var/opt/mssql --network backend mcr.microsoft.com/mssql/server:2019-latest

我还有三个 .netcore Web 应用程序(productapp1、productapp2、productapp3),它们分配给“后端”和“前端”网络。请参阅下面的 dockerfile 内容:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
COPY dist /app
WORKDIR /app
EXPOSE 80/tcp
ENTRYPOINT [ "dotnet", "DockerSample.dll" ]

这些是我用来创建它们的命令:

podman create --name productapp1 --network backend,frontend docker-sample
podman create --name productapp2 --network backend,frontend docker-sample
podman create --name productapp3 --network backend,frontend docker-sample

我还有一个使用以下命令分配给“前端”网络的 haproxy 容器:

podman run -d --name loadbalancer --network frontend --volume $(pwd)/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg -p 3000:80 --privileged haproxy:latest

haproxy的配置如下:

defaults
        timeout connect 5000
        timeout client 50000
        timeout server 50000
frontend localnodes
        bind *:80
        mode http
        default_backend mvc
        stats enable
        stats uri /stats
        stats refresh 1s

backend mvc
        mode http
        balance roundrobin
        server mvc1 productapp1:80
        server mvc2 productapp2:80
        server mvc3 productapp3:80

通过查看 Web 应用程序的日志,我可以确认它们按预期工作,没有任何问题。请参阅以下其中一个 Web 应用程序容器的日志:

warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
Applying Migrations...
Seed Data Not Required...
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app

问题是当我导航到 http://localhost:3000 时,我收到 503 Service Unavailable 消息。(没有可用的服务器来处理这个请求。)

我在其中一个 webapps 上运行了以下命令,并验证了 mssqlserver 的端口是可访问的:

podman exec -it productapp1 /bin/nc -zvw3 mssqlserver 1433

结果是:

DNS fwd/rev mismatch: mssqlserver != mssqlserver.dns.podman
mssqlserver [10.89.1.55] 1433 (?) open

但是,如果我为其中一个 Web 应用程序运行相同的命令:

podman exec -it productapp1 /bin/nc -zvw3 productapp2 80
podman exec -it productapp1 /bin/nc -zvw3 productapp2 5000

两者都返回连接被拒绝消息:

DNS fwd/rev mismatch: productapp2 != productapp2.dns.podman
productapp2 [10.89.1.57] 80 (?) : Connection refused

DNS fwd/rev mismatch: productapp2 != productapp2.dns.podman
productapp2 [10.89.1.57] 5000 (?) : Connection refused

我想知道是否有人可以对此有所了解,因为我一直在搜索和阅读很多内容,但无法弄清楚为什么这么简单的事情不应该起作用。

非常感谢。

谢谢。

更新 1:我忘了提到我也尝试过使用以下配置的 haproxy:

defaults
   timeout connect 5000
   timeout client 50000
   timeout server 50000
frontend localnodes
   bind *:80
   mode http
   default_backend mvc
   stats enable
   stats uri /stats
   stats refresh 1s
    
backend mvc
   mode http
   balance roundrobin
   server mvc1 productapp1:5000
   server mvc2 productapp2:5000
   server mvc3 productapp3:5000

更新 2:以下是我的 launchSettings.json 的内容

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:30113",
      "sslPort": 44371
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "DockerSample": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

我还尝试使用 -e ASPNETCORE_URLS=http://+:5000 创建容器,但仍然遇到相同的错误。

更新 3:将 launchSettings.json 更新为:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:30113",
      "sslPort": 44371
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "DockerSample": {
      "commandName": "Project",
      "launchBrowser": true,
      "applicationUrl": "https://+:5001;http://+:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

更新 4:在 Michael Hampton 的帮助下,我设法为我的 Web 应用程序容器打开了 5000 端口。我的 Web 应用程序容器的日志现在如下所示:

warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://[::]:5000
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app

我也可以从其他容器 netcat 这个端口:

DNS fwd/rev mismatch: productapp2 != productapp2.dns.podman
productapp2 [10.89.1.82] 5000 (?) open

我现在可以按预期导航到我的网络应用程序。

haproxy podman
  • 1 个回答
  • 870 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve