- Plesk for Linux
How to configure nginx to proxy requests from domains to a docker container in Plesk?
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).
- Ensure that nginx is running. Open Tools & Settings > Services management and ensure stat 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).
For this add a rule for nginx in the domain settings under 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 was 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.