Portainer: Jwilder/nginx-proxy

Created on 15 Nov 2016  ·  4Comments  ·  Source: portainer/portainer

Hello,
It seems that portainer is not working out of he box with jwilder/nginx-proxy.
It seems that location /ws should be set up in the reverse proxy for portainer being able to get data, am I correct?
Does anyone have a working config with jwilder/nginx proxy? Or any clue of how to set everything?
Regards

aredeployment deploymenreverse-proxy kinquestion

Most helpful comment

Hi @adi90x

I've got portainer running behind jwilder/nginx-proxy.

Here is what I've done to set it up:

  • Standard set up as per jwilder/nginx-proxy documentation (environment variable etc)
  • Add a location configuration file for portainer

If you take a look at this page: https://portainer.readthedocs.io/en/latest/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer

You will notice that the /portainer/ws/ location has some extra configuration. If you leave those out, you will get (at least in my case) an error message 'persistent connection closed' when attempting to accesss the portainer API.

I've added the following to my proxy configuration to solve that:

In /etc/nginx/vhost.d/portainer.myhostname.example_location:

proxy_http_version 1.1;
proxy_set_header Connection "";

See here for the jwilder/nginx-proxy documentation about the location file.

I don't know if there is a better way, but this does work for me.

All 4 comments

Hi @adi90x

I've got portainer running behind jwilder/nginx-proxy.

Here is what I've done to set it up:

  • Standard set up as per jwilder/nginx-proxy documentation (environment variable etc)
  • Add a location configuration file for portainer

If you take a look at this page: https://portainer.readthedocs.io/en/latest/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer

You will notice that the /portainer/ws/ location has some extra configuration. If you leave those out, you will get (at least in my case) an error message 'persistent connection closed' when attempting to accesss the portainer API.

I've added the following to my proxy configuration to solve that:

In /etc/nginx/vhost.d/portainer.myhostname.example_location:

proxy_http_version 1.1;
proxy_set_header Connection "";

See here for the jwilder/nginx-proxy documentation about the location file.

I don't know if there is a better way, but this does work for me.

Perfectly working ! Thanks a lot for the information !

If you want web tty console to work, you must add this lines in the previous file :

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Note: you can also replace :

proxy_http_version 1.1;
proxy_set_header Connection "";

with this simple line: proxy_set_header Connection $http_connection;.

This solution contradicts: https://github.com/jwilder/nginx-proxy/issues/705

here is suggested to use

└── vhost.d
└── app.mydomain.com_location

while the other linked issue suggests to use:

└── vhost.d
└── app.mydomain.com

None of these two work for me. After reading https://portainer.readthedocs.io/en/latest/faq.html#how-can-i-configure-my-reverse-proxy-to-serve-portainer it looks like one also needs to add another location:

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

Could someone clarify how to add this via the proxy?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davask picture davask  ·  3Comments

rnz picture rnz  ·  3Comments

yexingqi picture yexingqi  ·  3Comments

linquize picture linquize  ·  3Comments

cbrherms picture cbrherms  ·  3Comments