Question
How to create Nginx reverse proxy for Node.js application and let Nginx handle SSL on Plesk server?
Answer
If the Node.js and the application are configured via Plesk, as per this article: How to run Node.js application via Plesk, no further configuration is required. Nginx will act as a proxy serving HTTPS requests to the application on port 443.
Click on a section to expand
In case Node.js/application is configured manually
-
Uncheck
Proxy mode
option at Domain > example.com > Apache and Nginx Settings. -
Configure Nginx to forward all HTTPS requests made to the app domain URL to the port in which Node.js app is listening (in this example port 5500), adding the following additional directive below at Domains > example.com > Apache & Nginx Settings > Additional Nginx directives
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:5500;
}
- Click Apply button.