學習nginx代理服務器做負載均衡的使用
在本地安裝Nginx
1.下載nginx
http://nginx.org/en/download.html 下載穩定版本,以nginx/Windows-1.12.2為例,直接下載 nginx-1.12.2.zip
下載后解壓,解壓后如下
2.啟動nginx
有很多種方法啟動nginx
(1)直接雙擊nginx.exe,雙擊后一個黑色的彈窗一閃而過
(2)打開cmd命令窗口,切換到nginx解壓目錄下,輸入命令 nginx.exe 或者 start nginx ,回車即可
3.配置nginx的配置文件,是conf目錄下的nginx.conf
添加如下的加粗的部分后重新啟動nginx,只需要執行命令 nginx -s reload
#gzip on;
upstream tomcat_server{
server localhost:8080;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcat_server;
}
4.訪問127.0.0.1
此時會自動跳轉到 localhost:8080,也就是Jenkins的登錄頁面:http://127.0.0.1/login?from=%2F