-我利用namecheap申請一個domain name並且為它申請ssl認證
-然後我的網頁是在digital ocean的虛擬主機所架起來的
-在如果是在http連接的話會自動redirect到https的port
app.all('*',(req,res,next) =>{
if(req.secure){
console.log("secure!");
return next();
}
else{
res.redirect(307,'https://' + req.hostname + ':'+ app.get('secPort') + req.url);
}
});
-之後再利用Nginx反向代理連結到我的domain name
-但是Nginx一直沒辦法成功找到我的domain name
-而且每次打domain name都會變成my_ip:port
/etc/nginx/sites-enabled/default
server_name jiangdai.me;
location / {
proxy_pass http://my_ip:3000;
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;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
}