Plesk

How to proxy requests from domains to Docker container in Plesk?

Question

Docker containers can expose ports so applications inside them could be accessible via those ports.

But it is inconvenient to use the non-standard port in the website's URL to access an application.

How to proxy requests from domains to a Docker container to access the application in the container without using the non-standard port?

Answer

Note: Ensure that Nginx is installed before applying any steps. To check it open Tools & Settings  > Updates & Upgrades > Install components, fill in root password and press Next. On next screen ensure that nginx component is checked under Web hosting category and press Next to install it (if not installed).

  1. Log into Plesk.
  2. Go to Tools & Settings > Services management and ensure that nginx service is running. If nginx is not running, press Run (green button with "play" sign).
  3. Map the port inside a container to a port on the host system (for example, 32768) manually under Docker > select a container > Settings > clear the option "Automatic port mapping".
  4. Set up nginx to proxy requests from domains to that port, so domains can use a standard port on nginx (for example, 80).
    Go to Domains > example.com> Proxy Rules > Add Rule and specify the following:
    • URL. Specify the URL of the website that uses an application running in a container. It can be either the main website or a part of it.
    • Container. Select the application running as a Docker container.
    • Port. Select one of the mappings that were specified in the container settings (a port inside a container mapped to a port on your system). Nginx will proxy requests to the port on the system.

Additional information

Not possible to add Docker Proxy rules, no container is displayed

Exit mobile version