Nginx的隱藏式跳轉可以實現將請求跳到另一個網站的頁面,並且瀏覽器中URL保持不變。 Nginx設定中需要使用rewrite規則。下面提供兩個範例來說明這個跳轉需求的配置:
server { listen 443; server_name jb51.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; } }
server { listen 8082; server_name 172.16.60.16; index index.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隱藏式跳轉怎麼實現的詳細內容。更多資訊請關注PHP中文網其他相關文章!