多個網域名稱共用一個ip與port | nginx反向代理設定 Nginx Reverse Proxy Configuration
Multiple Domain Names Sharing a Single IP and Port | Nginx Reverse Proxy Configuration 會有這樣的需求是因為本來的網站 bian0726.com 是架設在 mac 裡面的虛擬機 網卡設定為橋接模式,跟實體機在同樣的網域 外部進來的連線,透過路由器進行轉發到虛擬機 但後來又多了 wp.bian0726.com 這個網站 這個網站架設在實體機上,使用同樣的固定 ip 以及 80 port 發現在路由器裡面沒有辦法進行這樣的設定 不過因為實體機裡面的網站是用 nginx 架設的 想說 nginx 應該會有可以設定的方式 就在網路上找到了 nginx 反向代理這個做法 反向代理有很多不同的設定方式 可以依照自己的需求進行調整 下面紀錄我的作法 進路由後台把外部連線改為轉發到實體機 虛擬機中的設定不需要改動 更改實體機的 nginx config 設定檔 重新載入 nginx 測試連線後,可以正常連線 這樣就完成了多個網域名稱共用一個 ip 與 port 的需求了 English version The need arises because the original website "bian0726.com" was set up on a virtual machine in a Mac. The network card was set to bridge mode, putting it in the same network as the physical machine. External connections were forwarded by the router to the virtual machine. However, later on a new website "wp.bian0726.com" was added. This new website is set up on the physical machine, using the same fixed IP and port 80. It was found that such a configuration could not be set up in ...