zoukankan      html  css  js  c++  java
  • 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设定到后者
                }
    }
    
  • 相关阅读:
    URL编码与解码
    什么通用数据交换格式更好
    JSON(JavaScript Object Notation)
    二维码与json都是数据交换格式
    数据的存在形式
    NSData、数据结构与数据转换
    物理结构与逻辑结构
    NSKeyedArchiver : NSCoder
    The Role of View Controllers
    Content-Type与MIME
  • 原文地址:https://www.cnblogs.com/YangGC/p/12219099.html
Copyright © 2011-2022 走看看