Home > Operation and Maintenance > Nginx > How to implement hidden jump in Nginx

How to implement hidden jump in Nginx

WBOY
Release: 2023-05-13 13:25:12
forward
1723 people have browsed it

Nginx's hidden jump can jump the request to a page on another website, and the URL in the browser remains unchanged. Rewrite rules need to be used in Nginx configuration. Two examples are provided below to illustrate the configuration of this jump requirement:

1. Nginx hidden jump configuration example 1

Change the request path to https:// jb51.net/data/test jumps to https://jb51.com/data/test/test.html page.

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;
    }
} 
Copy after login

2. Nginx Hidden Jump Configuration Example 2

Jump the request to access 172.16.60.16:8082/m2/order/secretRecording to 172.16.60.28 :8089/order/secretRecording

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;  #跳转
       }
}
Copy after login

The above is the detailed content of How to implement hidden jump in Nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template