1. 程式人生 > >nginx填坑補充(nginx根據上下文跳轉ip或者域名)

nginx填坑補充(nginx根據上下文跳轉ip或者域名)

store access allow tro 跳轉 head 不同的 域名 root

今天有一個需求,要根據上下文調到不同的ip或域名地址,使用上下文做域名跳轉的時候,proxy_pass域名後面一定要帶‘/’否則會把nginx的上下文自動帶入,這樣就行。

location ^~ /docs/ {
root html;
add_header Cache-Control no-store;
add_header ‘Access-Control-Allow-Origin‘ ‘*‘;
index index.html index.htm;
proxy_pass http://47.92.128.109:8080/;
}

location / {
root html;
add_header Cache-Control no-store;
add_header ‘Access-Control-Allow-Origin‘ ‘*‘;
index index.html index.htm;
proxy_pass http://cg.haier.net;
}

nginx填坑補充(nginx根據上下文跳轉ip或者域名)