nginx reverse proxy configuration to another server root directory

 

location /detail/json {
if ( $uri = "/detail/json" ) {
rewrite "/detail/json" /index.html break;
}
alias /data/web/static_test/detail/json/$host/;
proxy_pass http://192.168.1.2;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
index index.html;
default_type application/json;
proxy_redirect off;
proxy_intercept_errors on;
error_page 403 404 = @index;

location /lvpai/ware {
proxy_pass http://192.1.1.2:9997;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

location @index {
try_files $uri /lvpai/ware/$uri;
}

Interpretation: In the above configuration nginx 1.1 to 1.2 above the root path

If the address is accessed http: // resource domain / detail / json / xx actually get is a resource of 1.2 under the corresponding path

1.2 If the absence of resources to be accessed, then go try_files

 

Guess you like

Origin www.cnblogs.com/guniang/p/10932447.html