這裡用的是nginx for windows
首先進入nginx配置檔案,做以下配置:
server
{
listen 80;
server_name abc.com;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.16.10.87:80;
}
access_log logs/abccom.log;
}
然後啟動nginx,在cmd下,進入nginx根目錄,執行以下命令
start nginx
畫面一閃,nginx已經在後臺跑起來了
這樣所有通過abc.com訪問本機的請求,都會被nginx轉發到http://172.16.10.87:80上
其中server可以配置多個,來實現多個域名的不同轉發規則
關閉nginx服務可以執行以下命令
nginx -s quit
負載均衡:https://blog.csdn.net/qq_28602957/article/details/61615876