nginx——域名|端口|目录请求转发配置demo -尊龙游戏旗舰厅官网
尊龙游戏旗舰厅官网
收集整理的这篇文章主要介绍了
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的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: