Plesk

Using Docker – Setting up nginx to Proxy Requests from Domains to a Container

Some Docker containers expose ports so that applications in containers
could be accessible via those ports.

When you use an application in Docker container on your website, you may
find it inconvenient to specify the non-standard port in its URL. To
avoid inconvenience, you can set up nginx to proxy requests from domains
to that port, so domains can use a standard port (such as 80) and there
is no need to explicitly specify the port in URL.

Requirements

After you have mapped the port inside a container manually to some port
on your system (for example, 32768), you can set up nginx to proxy
requests from domains to that port, so domains can use a standard port
on nginx (for example, 80). To make this possible, add a rule for nginx
in the domain settings in the following way:

Go to Websites & Domains > the domain > Proxy Rules > Add
Rule
and specify the following:

 Proxy rules are implemented in the web server configuration, e.g., in
the website’s
file  nginx.conf (in /var/www/vhosts/system/$domain/conf/):

#extension docker begin
location ~ ^/.* {
    proxy_pass http://0.0.0.0:9080;
    proxy_set_header Host             $host;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
}
#extension docker end

Proxy rules should work fine on servers behind NAT.

Note: Docker containers connected via Proxy Rules to a website are not
counted towards the subscription’s disk space usage. An exception to
this would be when a website directory is mounted to a Docker
container as a volume, as in this case all files located in the
container will be counted towards the disk space usage of the
website.