為了在測試服務器上進行多種開發語言環境的Web項目演示,采用Nginx這個反向代理服務器。
對外只開放兩個端口即可,80和443。
采用域名反向到內部不同的項目中,只要支持HTTP/HTTPS的都可以反向過來。
目前測試過集成IIS、Apache、Tomcat三大流行Web服務器。
在低於Windows 2012的系統下,IIS的443只能一個證書,采用反向代理則可解決這個問題。
官網:
http://nginx.org/en/download.html
Windows版本:
(不建議生產環境中使用,性能比較差。生產還是用Linux比較好,Windows下的Nginx主要用於開發和演示)
http://nginx.org/download/nginx-1.16.0.zip
源碼:
http://nginx.org/download/nginx-1.16.0.tar.gz
配置為服務:
https://github.com/kohsuke/winsw/
https://github.com/kohsuke/winsw/releases/tag/winsw-v2.2.0
Your renamed winsw.exe
binary also accepts the following commands:
install
to install the service to Windows Service Controller. This command requires some preliminary steps described in the Installation Guide.uninstall
to uninstall the service. The opposite operation of above.start
to start the service. The service must have already been installed.stop
to stop the service.restart
to restart the service. If the service is not currently running, this command acts likestart
.status
to check the current status of the service.- This command prints one line to the console.
NonExistent
indicates the service is not currently installedStarted
to indicate the service is currently runningStopped
to indicate that the service is installed but not currently running.
- This command prints one line to the console.
配置啟動服務:
修改服務名稱等相關信息:
采用管理員命令提示符安裝服務:
計算機管理服務中可以查看到已經安裝好的服務:
配置虛擬主機:
單個文件反向代理樣本:
測試環境中注銷掉解析:
瀏覽器訪問成功!