nginx反向代理的使用

1、啓動nginx進程
start nginx
2.、退出nginx進程
nginx -s quit
3、重新加載配置文件
nginx -s reload
4、停止nginx進程
nginx -s stop
5、查看nginx 進程
rasklist /fi “imagename eq nginx.exe”
6、殺死相應nginx進程
taskkill /f pid 52356 /pid 3232
7、殺死所以的nginx進程
taskkill /fi “imagename eq nginx.exe” /f
爲什麼window下會起兩個nginx進程?
nginx是多進程來工作的,一個是master進程和多個worker進程
跳轉404頁面?
如果開啓的nginx過多,無法判斷當前使用的是哪個nginx,我們需要關閉其他nginx進程,如果當前接口無法找到會跳轉404頁面,
http 裏面配置 proxy_intercept_errors on;
GET http://localhost:8090/ 404(not found) 出現這種錯誤纔會跳轉404頁面
nginx 後臺配置
server:{
lister 8090;
server_name localhost;
//代理 本機啓動的服務
location /bclb/{
proxy_pass http://127.0.0.1:10006;
}
//代理其他機子的後臺服務
location /test/ {
proxy_pass http://10.2.177.11:8080/;
}
}
前端請求
http://localhost:8091(在本機跑的項目可以去掉)
axios(“http://localhost:8091/bclb/zzbzTybclb/getuser”).then((d)=>{console.log(d)})

axios("/bclb/zzbzTybclb/getuser").then((d)=>{console.log(d)})
代理地址前面如果不加 / 在請求的時候需要加 /
代理地址前面加 / 在請求的時候就不需要加 /
axios(“test/star”).then((d)=>{console.log(d)})

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章