//nginx伪静态
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
// 根目录放静态文件重写
location /web/{
index index.html;
try_files $uri $uri/ /web/index.html;
}
//重写 二级目录指向上级目录
location ^~ /h5/upload/ {
rewrite /h5/upload/(.*)$ /upload/$1 last;
}
//反向代理
location /api {
rewrite ^.+api/?(.*)$ /$1 break;
proxy_pass http://www.baidu.com; #node api server 即需要代理的IP地址
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /undefined {
rewrite ^.+undefined/?(.*)$ /$1 break;
proxy_pass http://google.com; #node api server 即需要代理的IP地址
}
location /api{ root /web; }
location /api{ rewrite ^/api/(.*)$ /web/api/$1 last; }
location /api{ alias /web/api; #这里写绝对路径 }
location /api{ rewrite ^/api/(.*)$ http://demo.com/web/api/$1; }
if ( $request_uri ~* ^(/api)){ rewrite ^/api/(.*)$ /web/api/$1 last; }