user3271784
user3271784

Reputation: 53

Docker nginx and Go (Golang) separate containers. Nginx configuration

On my localhost I've got Docker with 2 containers: Nginx and Golang. I want to do request from my local machine and get response from Go (localhost -> Nginx -> Go).

Containers work. I can go into Nginx container and run curl -v 'test:8080/path' -d "param1=value1&param2=value2" and I've got correct response.

But If I try to run the same request from host machine I've got an error - 502 Bad Gateway. If I change request and run curl -v -X POST 'test:8080/path' (same request without data) - It's ok.

My Nginx config:

server {
    listen 80;
    server_name test;

    client_max_body_size 20M;

    charset utf8;

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

I think, problem in Nginx configuration. But I'm newbie with nginx. Plz, help me :)

Upvotes: 0

Views: 1089

Answers (1)

user3271784
user3271784

Reputation: 53

My fault, guys. My Go program returns nothing. So nginx interpreted empty response as bad request and return 502.

Upvotes: 1

Related Questions