http://nginx.org/en/download.html
上傳到指定目錄中 /usr/local/srchtml
1.移動安裝目錄到指定文件nginx
mv nginx-1.19.4.tar.gz software/
2.修改文件名稱windows
mv nginx-1.19.4 nginx
說明:在源文件中執行以下命令tomcat
說明: nginx工做目錄說明
路徑:
命令:
1.windows命令:
1.啓動命令: start nginx
2.重啓命令: nginx -s reload
3.關閉命令: nginx -s stop服務器
2.Linux命令: 1.啓動命令: ./nginx 2.重啓命令: ./nginx -s reload 3.關閉命令: ./nginx -s stop
需求說明:
1.實現圖片反向代理
2.實現tomcat負載均衡實現
具體實現:
修改完成以後,重啓nginx服務器.負載均衡
#配置圖片代理服務器 http://image.jt.com:80 server { listen 80; server_name image.jt.com; location / { #root D:/JT-SOFT/images; root /usr/local/src/images; } } #配置商品後臺服務器 server{ listen 80; server_name manage.jt.com; location / { #代理真實服務器地址 #proxy_pass http://localhost:8091; #映射到集羣 #proxy_pass http://jtWindows; proxy_pass http://jtLinux; } } #配置tomcat服務器集羣 1.默認 輪詢策略 2.權重策略 3.ip_hash策略 upstream jtWindows { #ip_hash; down 標識宕機 backup 備用機 #max_fails=1 表示最大的失敗次數 #fail_timeout=60s 若是訪問不通,則在60秒內,不會再次訪問故障機 server 127.0.0.1:8081 max_fails=1 fail_timeout=60s; server 127.0.0.1:8082 max_fails=1 fail_timeout=60s; server 127.0.0.1:8083 max_fails=1 fail_timeout=60s; } upstream jtLinux { server 192.168.126.129:8081; server 192.168.126.129:8082; server 192.168.126.129:8083; }
說明:因爲沒有購買image/manage.jt.com的域名,因此須要經過hosts文件修改轉向.
修改windows中的hosts文件:spa
# 京淘配置 192.168.126.129 image.jt.com 192.168.126.129 manage.jt.com #IP 域名 映射關係 #127.0.0.1 image.jt.com #127.0.0.1 manage.jt.com 127.0.0.1 www.jt.com 127.0.0.1 sso.jt.com 127.0.0.1 localhost #bug 丟最後一個字母問題`