Process doc
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
該篇文章用於紀錄如何在 Synology NAS 開啟反向代理伺服器的狀況下,透過 Cloudflare 的 DNS 託管存取反向代理伺服器對應的服務。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Purpose
在僅開啟 443 端口的情況下,從外網存取在家用 Wi-Fi 路由器區網內的 NAS 內各內建與手動架設之服務。其中外網存取的方式為透過 Cloudflare 的 DNS 託管所設定的網域名稱進行存取,並且開啟 Proxy 避免 NAS 連線資訊(IP、額外設定的DDNS)外洩,此外在 Cloudflare 與 NAS 之間的連線加上 SSL 保護,避免資料外洩風險。
環境說明:
- NAS
- 對外網際網路(WAN)為固定 IP (範例
115.116.8.8
) 並連接家用 Wi-Fi 路由器 (若對外網路非固定 IP,需透過 NAS 與 Cloudflare 建立 tunnel)
- 網路環境位於家用 Wi-Fi 路由器內,假定分配之 IP 為 192.168.0.22
- 路由器僅轉發(Port forwarding) 443 port 給 NAS (代表只能透過 HTTPS 與 NAS 進行連線,Cloudflare 免費版也僅支援部分 Port)
- NAS 開啟 Synology 內建 DDNS 服務,如:
XXX.dscloud.me
(使用 Cloudflare 後可省略該操作)
- NAS 上的套件與手動架設之 Docker 服務,都透過反向代理伺服器進行存取,不開放任何 Port 讓外部存取,僅區域網路 IP 可透過 Port 進行存取。
- 假定 Synology Drive 頁面位於
10003
Port
- 使用內建 DDNS 與反向代理伺服器設定 (Drive 可於登入入口->應用程式直接設定,以下內容僅針對手動架設的 Docker 服務)
- 來源 (Source)
- 通訊協定:
https
- 主機名稱:
drive.XXX.dscloud.me
- Port :
443
- 目的地 (Destination)
- 主機名稱:
localhost
- Port:10003
- 存取結果如下
http://drive.XXX.dscloud.me
-不可存取(因為反向代理伺服器僅設定 443 Port,路由器也未轉發 80 Port)
https://drive.XXX.dscloud.me
-可存取(以下同理)
192.168.0.22
-不可存取
192.168.0.22:10003
-可存取
115.116.8.8
-不可存取
115.116.8.8:10003
-不可存取
- Cloudflare
- 申請任一個網域 (
example.com
)
- DNS Records 增加以下紀錄
- DNS Type A:
example.com
-> 115.116.8.8
nas.example.com
-> 115.116.8.8
- DNS Type CNAME:
drive.example.com
-> XXX.dscloud.me
(要綁定到 NAS 內建的 DDNS 也是可行的)
drive.example.com
-> drive.XXX.dscloud.me
(要綁定到 NAS 內建的 DDNS 也是可行的)
drive.example.com
-> nas.example.com
ANY_SERVICE_NAME.example.com
-> nas.example.com
預期結果:
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Step
詳細設定步驟,使得連線建立不會出現 error 522、error 526 等等錯誤。
NAS
- 若已使用內建 DDNS 設定好反向代理伺服器,還需額外設定一組來源為 Cloudflare 上的網域名稱。
- 若是內建的服務如 Synology Drive、Synology Photo,在 DSM 上簡單的設定只能從內建 DDNS 或 Cloudflare 選一個域名設定
- 內建 DDNS:
drive.XXX.dscloud.me
-> 192.168.0.22:10003
- Cloudflare DNS:
drive.example.com
-> 192.168.0.22:10003
- 防火牆要允許 Cloudflare Proxy 的 IP 存取
Cloudflare
-
於 DNS -> Records 設定 Type A 與 Type CNAME
-
於 SSL/TLS -> Overview 調整 SSL/TLS encryption mode 為 Full (strict)
- 若使用預設的 Flexible 代表 你跟 Cloudflare 的連線有被 SSL 加密 但 Cloudflare 跟 Synology NAS 的連線為加密
- Flexible 同時代表 Cloudflare 會透過 HTTP (80 Port) 去存取你的服務,這會導致找不到內容造成 Timeout (error 522),因為你的路由器未轉發 80 Port,同時 NAS 上的反向代理伺服器也只設定 HTTPS (443 Port) 的存取方式。
- 若改用則會讓 Cloudflare 跟 Synology NAS 的連線加密,代表 Cloudflare 會透過 HTTPS (443 Port) 去存取你的服務。
-
於 SSL/TLS -> Origin Server 產生你申請網域的 Certificate (Cloudflare 有提供 API 供自動化處理)
-
於 NAS 安裝上述申請的 Certificate
- 若未安裝 step.2 中 Cloudflare 與 NAS 的連線會因為認證無效而失敗 (error 526)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
-
於 NAS 上剛剛安裝的的 Certificate 設定使用該憑證的項目
- 若未進行設定,即使有安裝 Certificate ,連線到該網址時仍會碰到認證無效 (error 526)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
-
若在 step. 1 時設定 Type A 關閉 Proxy 改為 DSN only,則可不用設定憑證也不用調整 SSL/TLS encryption mode。
- 該方式相當於用內建的 DDNS 連線,連線方可以得知你的伺服器 IP 資訊,Cloudflare 不會對 NAS 進行保護