[英]How do I host a Node.js app on a subdomain from an apache2 VPS?
So, I have a Node.js app and I want to host it on a subdomain using my VPS.所以,我有一个 Node.js 应用程序,我想使用我的 VPS 将它托管在一个子域上。 My VPS is currently running apache2 and my Node.js app uses Express.
我的 VPS 目前正在运行 apache2,而我的 Node.js 应用程序使用 Express。 I have tried Phusion and have also tried this tutorial with no luck.
我尝试过Phusion ,也尝试过本教程但没有成功。 Also, my app uses Puppeteer which I'm not sure it makes a difference.
另外,我的应用程序使用了 Puppeteer,我不确定它是否有所作为。 I'm new to servers and web development so any help would be greatly appreciated.
我是服务器和 Web 开发的新手,因此将不胜感激。 Thank you.
谢谢你。
You can host the production-grade application with the help of Nginx & PM2 (node process manager) Instead of apache, you can give a try to Nginx since most of the NodeJS or Express application use NGINX as an HTTP proxy front of PM2.您可以借助 Nginx 和 PM2(节点进程管理器)托管生产级应用程序,您可以尝试使用 Nginx,因为大多数 NodeJS 或 Express 应用程序使用 NGINX 作为 PM2 的 HTTP 代理前端。 You need to do reverse proxy of your domain to
localhost:<port>
您需要将您的域反向代理到
localhost:<port>
Sample Nginx vhost,示例 Nginx 虚拟主机,
server {
server_name application.com;
location / {
proxy_pass http://<private-ip>:<port>;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
For setting up PM2 .用于设置PM2 。 Install this process manager globally.
全局安装此进程管理器。 For more reference you can check it here
如需更多参考,您可以在此处查看
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.