- Plesk for Linux
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?
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).
- Log into Plesk.
- 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).
- 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".
- 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.