Nginx 隐式跳转

来自Linux78|wiki

Nginx的隐式跳转可以实现将请求跳转到另一个网站的页面,并且浏览器中URL保持不变。以下配置示例将请求路径https://abc.com/home/test跳转到https://def.com/home/test/test.html页面。

server {
   listen       443;
   server_name  abc.com;  
   location = /home/test {
       rewrite /home/test /home/test/test.html break;
       proxy_pass https://def.com;
   }
}

线上实际配置示例,将访问192.168.10.54:1054/v2/aliyun/secretRecording的请求跳转到10.160.2.100:8089/aliyun/secretRecording:

查看源码打印?

server {
      listen 1054;
      server_name 192.168.10.54;
      index   index.html index.php index.htm;
      location ~* ^/v2/aliyun/secretRecording {
               proxy_next_upstream error timeout http_503 http_504 http_502;
               proxy_connect_timeout 500s;
               proxy_read_timeout 500s;
               proxy_send_timeout 500s;
               proxy_set_header Host $http_host;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               rewrite  ^(.*)$  /aliyun/secretRecording break;
               proxy_pass http://10.160.2.100:8089;
      }
}