2

This question already has an answer here:

I have the following docker-compose xml

web:
  build: nginx/.
  container_name: nginx
  ports:
    - "80:80"
  links:
    - "openchain"
  restart: always
wallet:
  build: wallet/.
  container_name: wallet
  ports:
    - "81:81"
  restart: always
  read_only: false
  volumes:
    - ./www:/usr/share/nginx/html:rw
  working_dir: /user/share/nginx/html
openchain:
  build: openchain/.
  ports:
    - "8080"
  volumes:
    - ./data:/openchain/data
  restart: always

And the following conf for web and wallet respectively

worker_processes 4;

events { worker_connections 1024; }

http {
    server {
        listen 80;

        location / {
            proxy_pass http://127.0.0.1:8080/;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
}

and

worker_processes 4;

events { worker_connections 1024; }

http {

server {
    listen 81;

    location / {
        root /usr/share/nginx/html;
    }
}

}

when I run docker ps I get

    05e351c8f8db        openchain_web         "nginx -g 'daemon off"   5 seconds ago       Up 5 seconds        0.0.0.0:80->80/tcp, 443/tcp    nginx
    e7401ea7c5bc        openchain_wallet      "nginx -g 'daemon off"   5 seconds ago       Up 5 seconds        80/tcp, 443/tcp,
0.0.0.0:81->81/tcp   wallet
    40439fdb1c69        openchain_openchain   "dotnet openchain.dll"   5 seconds ago       Up 5 seconds        0.0.0.0:32774->8080/tcp        openchain_openchain_1

But when I try to access the port openchain_openchain via proxy openchain_web I get the subject error

I'm new to docker so I'm not sure I'm proxying correctly with the nginx

Can you tell me what I did wrong?

P.S. I can access wallet just fine

marked as duplicate by kasperd, Michael Hampton nginx Oct 24 '18 at 16:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    As the new answer states, you must connect to the name of the other container, not to 127.0.0.1. – Michael Hampton Oct 24 '18 at 16:22
3

I used this configuration in my NGINX config where appsrv is the name of the docker-compose.yml service for the fastcgi image

server {

#listen 80 default_server;
listen 80;
#server_name xxxxxxxxx.com;
index index.php index.html;
root /var/www/html;

location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index            index.php;
    fastcgi_pass             appsrv:9000;
    include                  fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

client_max_body_size 200M;

}

  • 2
    Right. You have to connect to the name of the other container, not to 127.0.0.1. – Michael Hampton Oct 24 '18 at 16:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.