日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx——域名|端口|目录请求转发配置DEMO

發布時間:2024/10/5 Nginx 123 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx——域名|端口|目录请求转发配置DEMO 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、域名轉發?

upstream tomcat_taobao {server 192.168.71.129:8081; #訪問的tomcat的IP }server {listen 80; #監聽的對外端口server_name www.taobao.com; #域名location / {proxy_pass http://tomcat_taobao; #必須與服務器上對應的tomcat的upstream tomcat_taobao相對應index index.html index.htm;} }upstream tomcat_sina {server 192.168.71.129:8082; #訪問的tomcat的IP }server {listen 80;#監聽的對外端口server_name www.sina.com;#域名location / {proxy_pass http://tomcat_sina; #必須與服務器上對應的tomcat的upstream tomcat_sina相對應index index.html index.htm;} }

?2、端口轉發

server {listen 80;autoindex on;server_name www.port.com;access_log c:/access.log combined;index index.html index.htm index.jsp index.php;#error_page 404 /404.html;if ( $query_string ~* ".*[\;'\<\>].*" ) {return 404;}location / {proxy_pass http://127.0.0.1:8080;add_header Access-COntrol-Allow-Origin *;} }

3、目錄轉發?

server {listen 80;autoindex on;server_name www.stzg.com;access_log c:/access.log combined;index index.html index.htm index.jsp index.php;#error_page 404 /404.html;if ( $query_string ~* ".*[\;'\<\>].*" ) {return 404;}location / {root C:\file\img; # \是Windows /是Linuxadd_header Access-Control-Allow-Origin *;} }

4、負載均衡

//簡單的負載均衡,nginx支持ip_hash等分流,也支持插件自定義規則分流 upstream model{ server 127.0.0.1:8080server 127.0.0.1:8081server 127.0.0.1:8082 } server { listen 80;server_name localhost;location / { proxy_pass model; proxy_redirect default; } }

參考文章

https://blog.csdn.net/weixin_44550490/article/details/93369580

https://blog.csdn.net/kuaizisong/article/details/82790745

https://www.cnblogs.com/meetzy/p/8565507.html

https://www.jianshu.com/p/38810b49bc29

https://my.oschina.net/u/3703522/blog/1603984

總結

以上是生活随笔為你收集整理的Nginx——域名|端口|目录请求转发配置DEMO的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。