码迷,mamicode.com
首页 > 其他好文 > 详细

Nginx常用配置

时间:2020-01-20 20:49:21      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:lis   http   strategy   host   path   跳转   单点登录   cat   代理   

常用代理Server配置:

server {
    listen       80;    //监听的本地端口
    server_name  localhost;    
    
                
    location /api1/ {
        proxy_pass  http://localhost:8080; 
    }
    # http://localhost/api1/xxx -> http://localhost:8080/api1/xxx;
    
    
    location /api2/ {
        proxy_pass  http://localhost:8080/;
    }
    # http://localhost/api2/xxx -> http://localhost:8080/xxx;                    
    
    
    location /api3 {
        proxy_pass  http://localhost:8080;
    }
    # http://localhost/api3/xxx -> http://localhost:8080/api3/xxx;   
    
    
    
    location /api4 {
        proxy_pass  http://localhost:8080/;
    }
    # http://localhost/api4/xxx -> http://localhost:8080//xxx; 
    # 请注意这里的双斜线,好好分析一下
    
    
    
    location /api5/ {
        proxy_pass  http://localhost:8080/haha;
    }
    # http://localhost/api5/xxx -> http://localhost:8080/api4/hahaxxx;
    # 请注意这里的haha和xxx之间没有斜杠
}

携带Cookie配置:

常用于cas单点登录跳转

unstream 10api {
    server 192.168.1.10:8080;
}

server{
    location ^~ /prod-api/ {
                proxy_cookie_domain 10api $host;
                
                proxy_cookie_path /strategy /prod-api;
                #注意这里的路径 是两个不同的路径,中间有空格,把前者路径的cookie设定到后者
            }
}

Nginx常用配置

标签:lis   http   strategy   host   path   跳转   单点登录   cat   代理   

原文地址:https://www.cnblogs.com/YangGC/p/12219099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!