Comments (6)
@zaywalker Ok I was a little bit mistaken, I found out where the api/websocket requests are happening and it was indeed failing for me too. I found the source of the problem and it's actually Portainers documentation that was wrong. This is the advanced config I'm using and I can get to my consoles now:
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port;
}
Note that the proxy_pass
doesn't need a path and if one is set, it ignored the path of the request when it's forwarded. In this specific case, /api/websocket/exec
was being sent to /api/websocket/
and returning 400 errors for me.
from nginx-proxy-manager.
You're almost there, the advanced config actually gets inserted into the server block and the location /
is already forwarded, so all you need is the websocket part, this should work:
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port/api/websocket/;
}
from nginx-proxy-manager.
can't seem to get this working.
the generated config looks as following now:
# ------------------------------------------------------------
# portainer.docker
# ------------------------------------------------------------
server {
set $server 192.168.48.198;
set $port 9000;
listen 80;
server_name portainer.docker;
access_log /data/logs/proxy_host-2.log proxy;
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port/api/websocket/;
}
location / {
# Proxy!
include conf.d/include/proxy.conf;
}
}
However, it's still missing this section:
map $http_upgrade $connection_upgrade {
'' 'close';
default 'upgrade';
}
But i can't find a way to inject this into the generated config? Aside from editing the template in the docker image, that is.
from nginx-proxy-manager.
@jc21 Thanks for the answere! I've tried, but unfortunatly it didn't work for me. T_T But that's very good hint to learn how to use custom field. :)
these even I did, but it shows offline.
location / {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://$server:$port/;
}
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port/api/websocket/;
}
refer to @SGStino 's way, I've tried edit directly, but it didn't work. I guess
proxy_pass http://$server:$port/;
this one is problem.
When I remove that line, I can reach the web, but the web ui doesn't work properly. I can't open container's bash console just like before.
# ------------------------------------------------------------
# portainer.mydomain.com
# ------------------------------------------------------------
server {
set $server 192.168.123.123;
set $port 9000;
listen 80;
server_name portainer.mydomain.com;
# Asset Caching
include conf.d/include/assets.conf;
# Block Exploits
include conf.d/include/block-exploits.conf;
access_log /data/logs/proxy_host-9.log proxy;
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port/api/websocket/;
}
location / {
proxy_set_header Connection "";
proxy_http_version 1.1;
# Proxy!
include conf.d/include/proxy.conf;
}
}
Thanks again!
from nginx-proxy-manager.
@SGStino So this is a bit of a limitation at the moment, you can't specify any custom configuration for hosts that are meant to sit outside of the server
block. In your case, map
does in fact sit outside of the block and as a result, the $connection_upgrade
variable would be available to all nginx configurations options if it were to exist. I haven't found a nice, simple way to illustrate this in the interface yet. The goal of the software is to make life easy for people as much as possible. But I do want to have some more advanced configuration in there for users like yourself.
@zaywalker I'm using the latest Portainer myself (1.16.5 stable Docker version) and I'm not seeing any websocket upgrade requests at all in the interface. Even so, I've added the custom code I first mentioned to my proxy hosts and not only does the config show up on disk as part of the nginx config, it works just fine and reports online.
If you have a look at the proxy config template file you'll see where the advanced_config
is placed. You'll also see that there is already a location / {
section which cannot exist twice in the same server
block.
If v1.19 of Portainer absolutely needs the websocket upgrade, you should only need this advanced config content:
location /api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://$server:$port/api/websocket/;
}
When you save the Host in the interface and the host shows "Offline", hover the "Offline" text and you should see the error in the Tooltip. Let me know what that says
from nginx-proxy-manager.
@jc21 Oh thanks for the solution! It works perfectly!! thanks for the help! even I've learn a lot with this! Thansk!
from nginx-proxy-manager.
Related Issues (20)
- username and password forget HOT 1
- Feature Request - API Endpoint For Retrieving Generated TLS Certificates
- Allow closing popups/dialogs with Escape key
- No module named certbot HOT 2
- NPM passes through some requests even though 444 option is set HOT 2
- Enable ngx_stream_realip_module by default
- Login Credentials
- Proxy-Host creation via cli or api
- need huaweicloud DNS
- Using service names in docker swarm HOT 1
- [SECURITY] Possible Security Vuln HOT 3
- NPM template, or at mimimum copy a configuration
- Make "NPM automatically create custom DNS with pihole" an option.
- Internal error (to do with NodeJS?) when trying to make an SSL certificate HOT 3
- Can't create or renew certs because of SSLError(SSLError(1, '[SSL: TLSV1_UNRECOGNIZED_NAME] tlsv1 unrecognized name (_ssl.c:992)')). HOT 1
- Internal Error: josepy.errors.DeserializationError: Deserialization error: Expecting value: line 1 column 1 (char 0) HOT 1
- Response Header from /subfolder are wrong or missing HOT 1
- How to specify Custom locations correctly HOT 6
- Statistics on the dashboard HOT 1
- NginxProxyManager Cors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nginx-proxy-manager.