• nginx配置反向代理


    反向代理原理

    区别于正向代理,客户端对代理无感知,通过代理服务器将请求转发给真实服务器,获取返回数据后在发送给客户。

    主要配置文件:/usr/local/nginx/conf/nginx.conf

    案例1

    要实现的效果:在8080端口开启tomcat,在9001端口访问进入tomcat主页

    主要步骤

    1. 启动一个tomcat
    2. vim /usr/local/nginx/conf/nginx.conf 打开配置文件
    3. 配置server块如下:
        server {
            listen       9001;
            server_name  你的ip或者域名;
            location / {
                proxy_pass http://127.0.0.1:8080;
                proxy_connect_timeout 10;
                root html;
            }
    

    location后面可以带一个参数,是正则匹配的规则,如果满足规则才会采取以下的配置。

    1. 进入/usr/local/nginx/sbin 重启nginx
    ./nginx -s restart
    
    1. 访问你的域名的9001端口,发现能进入tomcat首页

    案例2 按访问路径规则转发

    要实现的效果 通过不同的路径访问8080端口或8081端口

    server{
    	listen 9001;
    	server_name localhost;
    	location ~ /edu/{
    		proxy_pass http://localhost:8080;
    	}
    	location ~ /vod/{
    		proxy_pass http://localhost:8081;
    	}
    }
    

    路径中带有edu则进入8080端口,带有vod则进入8081端口

  • 相关阅读:
    IfcBuildingStorey
    IfcBuilding
    IfcSpatialStructureElement (空间结构元素)
    IfcSpatialElement
    IfcProduct
    IfcPropertyDefinition
    IfcObject
    IfcObjectDefinition
    IfcRoot
    IfcTaskTime
  • 原文地址:https://www.cnblogs.com/PanYuDi/p/14591214.html
Copyright © 2020-2023  润新知