iT邦幫忙

1

架站之後nginx 找不到ip address

-我利用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;
    }

ayu iT邦好手 2 級 ‧ 2018-10-19 20:26:12 檢舉
j***.me, 授權NS(ns1/ns2/ns3.digitalocean.com)
就已回不出 A 或 CNAME Record, 目前只有
http://ipaddress:3000 和 8080 有回應.
而 www.j***.me 卻是有 A Record

至少要改 server_name 為 www.j***.me 吧
echochio iT邦高手 1 級 ‧ 2018-10-20 07:07:05 檢舉
沒仔細看.....
好像是

每次打域名都會變成 my_ip:port

那可以設 /etc/hosts 嗎?

設 hosts 比較簡單
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答