portainer: Console does not respond (behind NGINX proxy)

Description

Using Portainer behind NGINX reverse proxy with this configuration:

server {
        server_name portainer.example.id;
        location / {
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_pass http://localhost:9000;
        }
        location /api/websocket/ {
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_pass http://localhost:9000/api/websocket/;
        }
}

I opened a container’s console and connect using /bin/bash. The connection was successful, the terminal was opened and showing bash prompt, but it did not respond (i.e. typing any command did nothing).

The console works well if Portainer is accessed directly (http://example.id:9000).

Technical details:

  • Portainer version: 1.11.3
  • Portainer Docker image tag (latest/arm/windows…): latest
  • Target Docker version (the host/cluster you manage): 1.13.0
  • Platform (windows/linux): linux
  • Browser: Google Chrome 49

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

You mean that you need to use the following config ?

server {
        server_name i.sb;
        location /ui {
                proxy_http_version 1.1;
                proxy_set_header Connection "";
                proxy_pass http://localhost:9000/;
        }
        location /ui/api/websocket {
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_pass http://localhost:9000/api/websocket;
        }
}

I think there’s an erroneous (missing?) slash somewhere in a URI in the console stuff somewhere in the code, adding this extra location to the proxy config solves the problem with the console not working for me:

    location /api/websocket/exec {
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_http_version 1.1;
            proxy_pass http://portainer/api/websocket/exec;
    }

location /api/websocket/exec { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection “upgrade”; proxy_http_version 1.1; proxy_pass http://portainer/api/websocket/exec; }

I can confirm for at the time of this comment, this work perfectly. i had the issues on my proxy. Thanks @deviantony for the help!

I’m not sure if this is fixed or not.

My domain is a sub-sub-domain: sub.sub.main.net Portainer CE 2.18.4 Plesk acting as reverse proxy

My config:

location / {
	# Do not allow connections from docker 1.5 and earlier
	# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
	if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
		return 404;
	}

	proxy_pass                          http://localhost:9000;
	proxy_set_header  Host              $http_host;   # required for docker client's sake
	proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
	proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
	proxy_set_header  X-Forwarded-Proto $scheme;
	proxy_read_timeout                  900;
	client_max_body_size 10G;
}

I followed https://github.com/portainer/portainer/issues/609#issuecomment-280908861 and console works:

location / {
	# Do not allow connections from docker 1.5 and earlier
	# docker pre-1.6.0 did not properly set the user agent on ping, catch "Go *" user agents
	if ($http_user_agent ~ "^(docker\/1\.(3|4|5(?!\.[0-9]-dev))|Go ).*$" ) {
		return 404;
	}

	location /api/websocket/exec {
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "upgrade";
		proxy_http_version 1.1;
		proxy_pass http://localhost:9000/api/websocket/exec;
	}

	proxy_pass                          http://localhost:9000;
	proxy_set_header  Host              $http_host;   # required for docker client's sake
	proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
	proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
	proxy_set_header  X-Forwarded-Proto $scheme;
	proxy_read_timeout                  900;
	client_max_body_size 10G;
}

Honestly, no idea and I don’t really have time to debug reverse proxy configs at the moment. My suggestion is that if you found a working configuration, just use it 😃

Otherwise you can join us on Slack, we have a dedicated channel where we can discuss reverse-proxies issues: http://portainer.io/slack/