![](/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.