Nginx configures the / path forwarded by proxy_pass

Request original address: http://servername/static_js/test.html

copy code

location ^~ /static_js/
{
    proxy_cache js_cache;
    proxy_set_header Host js.test.com;
    proxy_pass http://js.test.com/;
}

or use rewrite

location ^~ /static_js/ 
    proxy_cache js_cache; 
    proxy_set_header Host js.test.com; 
    rewrite /static_js/(.+)$ /$1 break; 
    proxy_pass http://js.test.com

copy code

Proxy as  http://js.test.com/test.html

copy code

location ^~ /static_js/
{
    proxy_cache js_cache;
    proxy_set_header Host js.test.com;
    proxy_pass http://js.test.com;
}

copy code

Proxy as  http://js.test.com/static_js/test.htm

 

Domain jump to visit crm6yy_proxy.xxx.com Jump to crm6yy.xxx.com

1

2

3

4

5

6

7

8

9

10

11

server {

 

        listen 80  ;

        server_name crm6yy_proxy.xxx.com;

        location / {

            proxy_set_header Host $host;

            proxy_set_header X-Real-Ip $remote_addr;

            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_pass http://crm6yy.xxx.com/;

        }

}   

  forward proxy 

Scenes

A cannot access the Internet

B can access the Internet (A and B can access each other)

C outside the website http://www.baidu.com

 

The nginx configuration on B is as follows

copy code

resolve 8.8.8.8;  
    server {  
        listen       8090;  
  
        location / {  
                proxy_pass $scheme://$http_host$request_uri;  
        }  
    }

copy code

use:

Access on machine A:

or curl -x B:8090 -k "C"

或者 export http_proxy="http://B:8090"

Or under windows: fill in the ip and port in internet options->connection->LAN settings->proxy server

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324431173&siteId=291194637