• Nginx地址转发


    server {
            listen       80;
            server_name  demo.com;
    
            location / {
                root   /usr/share/nginx/html;
                index  index.html index.htm;
            } 
    
            # 第一种:proxy_pass中,不带『path』,则把『匹配字符串及后缀(/api/xxx)』均带给转发地址
            # 效果是: http://xxx.xxx.com/api/xxx --> http://127.0.0.1:7000/api/xxx. 转发的时候,包含了url前缀.
            location ^~ /api/ {
                proxy_pass  http://127.0.0.1:7000; 
            }
    
            # 第二种:proxy_pass中,带『path』如『/』或者『/api』,则把『排除匹配字符串后的path(/xxx)』均带给转发地址
            # 效果是: http://xxx.xxx.com/api/xxx --> http://127.0.0.1:7000/xxx. 转发的时候,包含了url前缀.
            location ^~ /api/ {
                proxy_pass  http://127.0.0.1:7000/; 
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
    
       }
    }
    
  • 相关阅读:
    oracle 失效对象自动重新编译
    Apache commons 工具集简介
    正则表达式 元字符
    LayUI之弹出层
    Js和JQuery基础
    单点登录
    java算法题
    SpringBoot自定义注解
    SpringBoot基础
    java面试题
  • 原文地址:https://www.cnblogs.com/testopsfeng/p/13926277.html
Copyright © 2020-2023  润新知