• Nginx常用配置


    常用代理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设定到后者
                }
    }
    
  • 相关阅读:
    mongodb
    python中读取文件的read、readline、readlines方法区别
    uva 129 Krypton Factor
    hdu 4734
    hdu 5182 PM2.5
    hdu 5179 beautiful number
    hdu 5178 pairs
    hdu 5176 The Experience of Love
    hdu 5175 Misaki's Kiss again
    hdu 5174 Ferries Wheel
  • 原文地址:https://www.cnblogs.com/YangGC/p/12219099.html
Copyright © 2020-2023  润新知