Nginx隐藏式跳转(浏览器URL跳转后保持不变)

【Nginx隐藏式跳转(浏览器URL跳转后保持不变)】Nginx的隐藏式跳转可以实现将请求跳转到另一个网站的页面,并且浏览器中URL保持不变。Nginx配置中需要使用rewrite规则。下面提供两个示例来说明这种跳转需求的配置:
一、Nginx隐藏式跳转配置示例1 将请求路径https://jb51.net/data/test跳转到https://jb51.com/data/test/test.html页面。

server {listen443; server_namejb51.net; access_log/data/nginx/logs/jb51.net-access.log main; error_log/data/nginx/logs/jb51.net-error.log; ssl on; ssl_certificate /data/nginx/ssl/jb51.net.crt; ssl_certificate_key /data/nginx/ssl/jb51.net.key; ssl_session_timeout 5m; location = /data/test {rewrite /data/test /data/test/test.html break; proxy_pass https://jb51.com; }} 

二、Nginx隐藏式跳转配置示例2 将访问172.16.60.16:8082/m2/order/secretRecording的请求跳转到172.16.60.28:8089/order/secretRecording
server {listen 8082; server_name 172.16.60.16; indexindex.html index.php index.htm; location ~* ^/m2/order/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^(.*)$/order/secretRecording break; #先改写URI地址proxy_pass http://172.16.60.28:8089; #跳转}}

更多关于Nginx隐藏式跳转的文章请查看下面的相关链接

    推荐阅读