zoukankan      html  css  js  c++  java
  • 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;
            }
    
       }
    }
    
  • 相关阅读:
    分割线
    PTA 乙级 1053 住房空置率 (20分) C/C++
    5.12 记录
    单词统计
    eclipse导入项目jdk版本不一样
    5.6日 项目回顾
    5.5 记录
    5.3 记录
    5.2 记录
    5.1 记录
  • 原文地址:https://www.cnblogs.com/testopsfeng/p/13926277.html
Copyright © 2011-2022 走看看