zoukankan      html  css  js  c++  java
  • nginx下根据指定路由重定向

      前言:

      最近在搭建vue后台,后端接口是PHP写的,线上构建好之后,需要请求其他域名下的接口,开发环境已经使用proxytable解决了接口问题,为了开发和生成的代码一致,

    编译后的代码,放在nginx下运行,配置了路由重写。

      项目说明:

    前端页面域名 front.me,后端接口backend.me,前端访问后端接口都是请求front.me/api/controller/action,nginx配置了重定向,当检测到路由里面/api/是会重定向到 backend.me/controller/action,下面是完整配置,其中重定向配置,我加了说明

      

    server
        {
            listen 9929 default_server;
            server_name _;
            index index.html index.htm index.php;
            root  /data/web/eyeSkyAdmin/dist;
            include enable-php-pathinfo.conf;
            location /nginx_status
            {
                stub_status on;
                access_log   off;
            }
    
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }
    
            location ~ .*.(js|css)?$
            {
                expires      12h;
            }
    
            location ~ /.well-known {
                allow all;
            }
    
            location ~ /.
            {
                deny all;
            }
            #这段是指定路由重定向配置start
            location /api/{
                rewrite ^/proxy/html/(.*)$ /$1 break;
                proxy_pass http://backend.me/;
            }
            #这段是指定路由重定向配置end
            access_log  /home/wwwlogs/access.log;
        }    

      

  • 相关阅读:
    android进度条
    编解码器的学习笔记(十):Ogg系列
    logcat使用
    KNN算法的理解
    Ewebeditor最新漏洞和漏洞指数
    HDU 4945 2048(DP)
    喜大本\ u0026普,微软的开源
    Problem A: Artificial Intelligence?
    Response.Redirect 打开这两种方法的一种新形式
    java Map 之 排序(key,value)
  • 原文地址:https://www.cnblogs.com/IT--Loding/p/10368459.html
Copyright © 2011-2022 走看看