• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Docker proxy rules not working

Godehardt2003

New Pleskian
Server operating system version
Ubuntu 18.04.6 LTS
Plesk version and microupdate number
Plesk Obsidian 18.0.45
Hello,
first of all I'm a very newbie on Plesk. But everything worked for me until now.
So I have a Docker container running Gitea. Gitea is running perfectly with the Docker extension in Plesk.
It has a manual port mapping:
1660859706418.png
So far so good. I also added a docker proxy rule:

1660859839028.png
If I go to this link (https://domain.com/test) I get a 404 not found error.
Then I tried different approaches. https://domain.com:3000 is throwing this error:
1660859995416.png
It's irrelevant if I create a docker proxy rule or not.

Also a subdomain is not working. Then I get the default Plesk page. Irrelevant if proxy rules are enabled or not...

I'm at a point where I don't know how to continue now.

Thanks a lot!
 
Hello @Godehardt2003

As for
Then I tried different approaches. https://domain.com:3000 is throwing this error:
I got the same and it's caused by the fact gitea is running http by defaul, so I have HTTP://domain.com:3000 leading me to the app (gitea install page) in a docker container in Plesk

As for this
If I go to this link (https://domain.com/test) I get a 404 not found error.
The root cause is in this Usage: Reverse Proxies - Docs . If you make a proxy to the domain's root (like leaving empty the field URL on the domain's Docker Proxy Rules page) it is going to work just fine. But in case of subfolder paths the requests are proxied to the subfolder URL istead of the app root (it's an app requirement):
Screenshot 2022-08-19 at 15.54.27.png
This is a know thing to improve in the Docker extension with ID PPM-2869. It is planned to be implemented in one of the future versions of the extensions (however, no exact ETA is available).

I see the following solutions:
  1. Proxy requests from domain's root like Domain Names - Buy a Website Domain - Domain.com (just create a Docker Proxy Rule leaving the URL field empty)
  2. Instead of configuring proxy rule via Docker Proxy Rules page on the domain's card add your own custom additional directives for Nginx config of this domain in Domains -> domain.com -> "Hosting & Dns" tab -> Apache & nginx Settings -> scroll down to additional directives. For example, as below (note the location /test/ and the slash after port 3000):

    Screenshot 2022-08-19 at 16.02.06.png
    Code:
    location /test/ {  
        proxy_pass http://0.0.0.0:3000/;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
  3. Create a subdomain, e.g. test.domain.com and create a Docker Proxy Rule for this subdomain's root like in the first solution. You will get the app on test.domain.com which is not the same as domain.com/test/ but still close enough depending on your needs.
Note! Don't forget to add additional evironment variable ROOT_URL according to the gitea docs in the container settings in Plesk:
Then you MUST set something like [server] ROOT_URL = http://git.example.com/git/ correctly in your configuration.
For the second solution it will look like this:
Screenshot 2022-08-19 at 16.03.30.png

At least, I was able to run gitea via second solution + this ROOT_URL env variable. Hope this helps.
 
Last edited:
Hello @Godehardt2003

As for

I got the same and it's caused by the fact gitea is running http by defaul, so I have HTTP://domain.com:3000 leading me to the app (gitea install page) in a docker container in Plesk

As for this

The root cause is in this Usage: Reverse Proxies - Docs . If you make a proxy to the domain's root (like leaving empty the field URL on the domain's Docker Proxy Rules page) it is going to work just fine. But in case of subfolder paths the requests are proxied to the subfolder URL istead of the app root (it's an app requirement):
View attachment 21407
This is a know thing to improve in the Docker extension with ID PPM-2869. It is planned to be implemented in one of the future versions of the extensions (however, no exact ETA is available).

I see the following solutions:
  1. Proxy requests from domain's root like Domain Names - Buy a Website Domain - Domain.com (just create a Docker Proxy Rule leaving the URL field empty)
  2. Instead of configuring proxy rule via Docker Proxy Rules page on the domain's card add your own custom additional directives for Nginx config of this domain in Domains -> domain.com -> "Hosting & Dns" tab -> Apache & nginx Settings -> scroll down to additional directives. For example, as below (note the location /test/ and the slash after port 3000):

    View attachment 21409
    Code:
    location /test/ {  
        proxy_pass http://0.0.0.0:3000/;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
  3. Create a subdomain, e.g. Blank Title and create a Docker Proxy Rule for this subdomain's root like in the first solution. You will get the app on Blank Title with is not the same as https://domain.com/test/ but still close enough depending on your needs.
Note! Don't forget to add additional evironment variable ROOT_URL according to the gitea docs in the container settings in Plesk:

For the second solution it will look like this:
View attachment 21410

At least, I was able to run gitea via second solution + this ROOT_URL env variable. Hope this helps.
Thanks for your answer. Fixed it myself a few minutes ago... Very very simple. Sorry for that but as I said I'm a newbie.

I only tried it via the subdomain and it worked instantly!
 
The solution is to modify your nginx.conf file to rewrite the URL before passing it to the container, like this:

NGINX:
location /test/ {
    rewrite /test/(.*) /$1 break;
    proxy_pass http://0.0.0.0:3000/;
    proxy_set_header Host              $host;
    proxy_set_header X-Real-IP         $remote_addr;
    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
}

Hopefully this will also be implemented into the extension soon, that planned improvement is still not here yet.
 
@mihaitha
Thanks for your input. Just a small addition. Manual changes to the domain's nginx configuration files will be overwritten each time any hosting settings are changed using the Plesk user interface. So it is recommended to use additional nginx directives for this as I mentioned in the second solution of my previous answer. This way, the changes will be saved regardless of any domain configuration changes.
 
@ddmitrienko That is correct. However if you also have a Docker container that the root URL of the domain / subdomain points to via A Docker proxy rule, it will take precedence over the secondary URL ones, due to where the include statement is in the nginx config. So what I had to do was to write all the location statements as additional nginx directives, to make sure that the root container is the last one, and not use the Docker Proxy Rules feature at all.
 
Hello @Godehardt2003

As for

I got the same and it's caused by the fact gitea is running http by defaul, so I have HTTP://domain.com:3000 leading me to the app (gitea install page) in a docker container in Plesk

As for this

The root cause is in this Usage: Reverse Proxies - Docs . If you make a proxy to the domain's root (like leaving empty the field URL on the domain's Docker Proxy Rules page) it is going to work just fine. But in case of subfolder paths the requests are proxied to the subfolder URL istead of the app root (it's an app requirement):
View attachment 21407
This is a know thing to improve in the Docker extension with ID PPM-2869. It is planned to be implemented in one of the future versions of the extensions (however, no exact ETA is available).

I see the following solutions:
  1. Proxy requests from domain's root like Domain Names - Buy a Website Domain - Domain.com (just create a Docker Proxy Rule leaving the URL field empty)
  2. Instead of configuring proxy rule via Docker Proxy Rules page on the domain's card add your own custom additional directives for Nginx config of this domain in Domains -> domain.com -> "Hosting & Dns" tab -> Apache & nginx Settings -> scroll down to additional directives. For example, as below (note the location /test/ and the slash after port 3000):

    View attachment 21409
    Code:
    location /test/ { 
        proxy_pass http://0.0.0.0:3000/;
        proxy_set_header Host              $host;
        proxy_set_header X-Real-IP         $remote_addr;
        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
  3. Create a subdomain, e.g. test.domain.com and create a Docker Proxy Rule for this subdomain's root like in the first solution. You will get the app on test.domain.com which is not the same as domain.com/test/ but still close enough depending on your needs.
Note! Don't forget to add additional evironment variable ROOT_URL according to the gitea docs in the container settings in Plesk:

For the second solution it will look like this:
View attachment 21410

At least, I was able to run gitea via second solution + this ROOT_URL env variable. Hope this helps.

Hi

I am trying to install gitea via Docker.
I want use under my subdomain like: git.mydomain.com
So firstly i add a the subdomain. As next I edit the gitea container settings like:


1667388064173.png

The cointainer has also start sucessfuly:
1667388222680.png

under the main domain I also add following additional nginx directives:
1667388308642.png

The Subdomain is behind Cloudflare Proxy as CNAME Record
1667388551404.png

Unfortunately, I get a 403 Error
1667388636665.png

I would be very thankfull if you have some suggesion to solve my issue.

Thanks
 
Back
Top