Applicable to:
- Plesk Obsidian for Linux
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
-
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
CONFIG_TEXT: 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.
Comments
1 comment
This method works but then shows the domainname:port in the url bar, is there a way to do this with hiding the port?
when i added the lines
server_name_in_redirect off;
proxy_set_header Host $host:$server_port;
i get a 400 bad request error
Please sign in to leave a comment.