• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Docker Proxy Rules - Getting 404 on the URL set

Jon123

New Pleskian
I have a Docker container set up and running (Portainer).
I set the port mapping to manual, 9000 to 39000.
The service is available and running at domain.com:39000

I went to:
Domain> Docker Proxy Rules
I added a rule using these settings:
URL: domain.com/portainer
Container: portainer
Port: 9000->39000

Basically, the only thing I can change here is the URL - since the container and port mappings are the only ones available (which makes sense).

When I visit domain.com/portainer I get a 404.
I've tried copying/pasting the URL, just to be sure.
I have confirmed that nginx reverse proxy is enabled for the domain.
I have tried restarting the service and the Docker container a few times.

Any ideas?
 
I have this partially working using a custom nginx directive, but something is still not right and I don't know what...

# Custom docker reverse proxy settings begin
location /portainer/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://0.0.0.0:39000/;
}

location /portainer/api/websocket/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_pass http://0.0.0.0:39000/api/websocket/;
}
# Custom docker reverse proxy settings end


Now, the strange thing here is that if I leave the location as "/portainer/", I get nginx's 404 (whether I open the url with or without the trailing slash).
If I remove the trailing slash in the config, I get in to the portainer container, but it has some kind of error (that doesn't happen when accessed directly via its port).

I have this same configuration on a reverse proxy I run on a different server (non-plesk), and the config as I pasted it above works perfectly.. So I'm lost now.
 
Plesk's customer service helped out on this one, I just wanted to share in case anyone came across this in the future.

From Taras @ Plesk:

When the proxy rule is created for the domain's root the requests for the domain's root are proxied to the application's root in the container. Thus, everything works properly - the application works correctly on Example Domain.

However, when a subfolder is specified in the field URL in the proxy rule, the application in the container returns the error 404 (because not Plesk-branded 404 page is shown).

It is caused by the fact that in this case, the requests are proxied not to the application's root in the container, but to the same sub-URL as in the proxy rule (domain.com:39000/portainer in your case).

I clarified this behavior with our development team, and they confirmed that currently, it is expected behavior. For such purposes, they recommend creating a subdomain (e.g. portainer.domain.com) and create a proxy rule for the subdomain's root.

So it will be possible to proxy requests from http://example.com/folder to the application's root in the container, the development team created a point for improvement for the Docker extension with ID PPM-2869. It is planned to be implemented in one of the future versions of the extensions (no exact ETA is available).
 
The solution is to modify your nginx.conf file to rewrite the URL before passing it to the container, like this:

NGINX:
location /portainer/ {
rewrite /portainer/(.*) /$1 break;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://0.0.0.0:39000;
}

Hopefully this will also be implemented into the extension soon, that planned improvement is still not here yet.
 
Back
Top