【问题标题】:Docker nginx and Go (Golang) separate containers. Nginx configurationDocker nginx 和 Go (Golang) 分离容器。 Nginx 配置
【发布时间】:2015-12-31 00:28:07
【问题描述】:

在我的本地主机上,我有 Docker 和 2 个容器:Nginx 和 Golang。我想从本地机器发出请求并从 Go (localhost -> Nginx -> Go) 获得响应。

容器工作。我可以进入 Nginx 容器并运行 curl -v 'test:8080/path' -d "param1=value1&param2=value2" 我得到了正确的回应。

但是,如果我尝试从主机运行相同的请求,则会出现错误 - 502 Bad Gateway。如果我更改请求并运行curl -v -X POST 'test:8080/path'(没有数据的相同请求) - 没关系。

我的 Nginx 配置:

server {
    listen 80;
    server_name test;

    client_max_body_size 20M;

    charset utf8;

    location / {
        proxy_pass http://go:8000;  // there go - docker compose link
    }
}

我认为,Nginx 配置有问题。但我是 nginx 的新手。请帮帮我:)

【问题讨论】:

    标签: nginx go docker docker-compose


    【解决方案1】:

    我的错,伙计们。我的 Go 程序什么也不返回。所以nginxempty 响应解释为错误请求并返回502。

    【讨论】:

    • 我知道这是旧的,但你返回了什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 2018-02-18
    • 2021-09-30
    • 2016-10-13
    • 2021-05-11
    • 1970-01-01
    相关资源
    最近更新 更多