![](/img/trans.png)
[英]is it best practice to bind uncaughtException event to handle error occurs in callback nodejs?
[英]Best practice to handle vhosts in nodejs
在node.js中处理虚拟主机的最佳实践是什么?
我需要将域路由到每个单独的http服务器。
http://api.localhost:8080 => localhost:9000
http://www.localhost:8080 => localhost:9001
https://secure.localhost:8080 => localhost:9002 // this request is HTTPS
我正在使用快递http
通常在端口80上使用nginx,然后使用对节点服务器的反向代理在nginx中定义服务器(虚拟主机)。 之所以如此普遍,是因为nginx在提供静态内容方面表现出色,因此您可以通过告诉它您的公共目录位置来做到这一点。
这是服务器(虚拟主机)配置的示例。 您将创建一个server { }
块,并为每个虚拟主机更改server_name:
server {
listen 80;
server_name website.com;
location / {
proxy_pass http://127.0.0.1:3001;
}
location ~* ^.+\.(jpg|png|gif|woff|ico|map|js|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|flv|swf|html|htm)$ {
root /home/empurium/code/davinci/public;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.