0
点赞
收藏
分享

微信扫一扫

nginx rewrite重定向访问本地其它目录,并且保留请求的地址和端口

背景

通过k8s访问http://192.168.1.2:32156/devops/index.html需跳转到http://192.168.1.2:32156/jenkins/

配置文件

location = /devops/index.html {             
rewrite ^ $scheme://$http_host/jenkins/ permanent;
}
location = /jenkins/ {
root /usr/share/nginx/html;
index /jenkins/index.html;
}

相关解释

location = /devops/index.html   #精准匹配/devops/index.html
$scheme #存放了客户端请求使用的协议,如http
$http_host #存放客户端请求的地址+端口,如192.168.1.2:32156

参考文章:

​​http://www.cocoachina.com/articles/39379​​

Nginx中的Rewrite的重定向配置与实践

举报

相关推荐

0 条评论