【问题标题】:Nginx proxy to CFSS Connection refusedNginx 代理到 CFSS 连接被拒绝
【发布时间】:2020-04-20 21:27:53
【问题描述】:

我有 CFSSL 服务在 kubernetes 的端口 8888 上运行。我可以从另一个直接引用 cfssl:8888 的 pod 访问它的 API。我想通过 Nginx 公开它,我让 Nginx 在单独的 pod 中运行,配置如下

upstream cfssl {
    server cfssl:8888;
}

server {
    listen         80 default_server;
    listen         [::]:80 default_server;
    server_name    localhost;

    location / {
        proxy_pass http://cfssl;
        proxy_set_header Host cfssl;
    }
}

但是这个 Nginx 配置不起作用,我可以访问 cfssl:8888 wethin Nginx pod,但是当我这样做时 curl localhost:80

curl: (7) Failed to connect to localhost port 80: Connection refused

这个设置有什么问题?

【问题讨论】:

    标签: nginx kubernetes cfssl


    【解决方案1】:

    在 location 块中你没有提到端口

    location / {
            proxy_pass http://cfssl;
    

    应该是这样的

    server {
        listen         80 default_server;
        listen         [::]:80 default_server;
        server_name    localhost;
    
        location / {
            proxy_pass http://cfssl:8888;
            proxy_set_header Host cfssl;
        }
    

    【讨论】:

    • 我试过这个,当我在 nginx 容器中 curl localhost:80, curl localhost 或 curl nginx:80, curl nginx 时仍然出现同样的错误
    • 如果你使用容器你不能写入口吗?
    猜你喜欢
    • 2017-08-07
    • 2013-03-02
    • 2020-09-16
    • 2021-01-16
    • 1970-01-01
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    • 2014-05-18
    相关资源
    最近更新 更多