nginx反向代理和rewrite进行解决跨域问题、去掉url中的一部分字符串,通过nginx正则生成新的url
来源:互联网 发布:信息工程研究所 知乎 编辑:程序博客网 时间:2024/06/07 02:57
场景:表面上访问的是http://127.0.0.1:7777/test/xhtml//tpl/app-tpl-webapp/css/base.css,
实际上看的是http://127.0.0.1:8888/tpl/app-tpl-webapp/css/base.css的内容。
server {
listen 7777;server_name 127.0.0.1;
location ^~ /website-webapp {
proxy_pass http://127.0.0.1:8888;
}
location ^~ /app-tpl-webapp {
proxy_pass http://127.0.0.1:8888;
}
location ^~ /tpl {
proxy_pass http://127.0.0.1:8888;
}
location ~ .*/tpl/ {
#alias E:/UCMSServer/tomcat/webapps/tpl/;
#index index.shtml index.html index.htm;
rewrite ^/(.*)/tpl/(.*)$ http://127.0.0.1:7777/tpl/$2; #其中$2表示的是正则中的第二串
}
location ^~ /preview {
proxy_pass http://127.0.0.1:8888;
}
}
以下方式是正则匹配以mp4结尾的方式
location ~ \.mp4$ {
root /data;
mp4;
mp4_buffer_size 1m;
mp4_max_buffer_size 500m;
}
0 0
- nginx反向代理和rewrite进行解决跨域问题、去掉url中的一部分字符串,通过nginx正则生成新的url
- nginx和apache下的url rewrite
- nginx和apache下的url rewrite
- nginx反向代理时通过rewrite解决后端资源css/js/img 写了绝对路径的问题
- Nginx反向代理解决跨域问题
- nginx反向代理解决跨域问题
- (Nginx) URL REWRITE
- nginx rewrite url
- nginx rewrite url 重写
- Nginx 配置反向代理后,页面中取绝对URL地址的问题显示代理端口
- Nginx反向代理新篇-使用location对多个URL做反向代理
- nginx配置url重定向-反向代理
- [问题记录]按url context path设置nginx反向代理禅道和Jenkins
- nginx rewrite和根据url参数location
- 前端接口调试 -- 通过Nginx反向代理机制解决跨域问题
- Apache和Nginx设置伪静态(URL Rewrite)的方法
- 通过vue dev和nginx反向代理实现跨域
- nginx url rewrite 的问号规则
- 从上往下打印二叉树
- COBOL call C function
- 单链表基础
- Java-003-朝花夕拾
- 初次使用servlet写HelloWorld
- nginx反向代理和rewrite进行解决跨域问题、去掉url中的一部分字符串,通过nginx正则生成新的url
- COBOL PERFORM verb
- iOS库-库的基本常识
- HDU 1542 Atlantis 【线段树+扫描线】
- springmvc的进阶
- http://www.uisdc.com/front-end-designer-cooperation
- 自定义对话框
- java程序运行机制和jvm
- COBOL OPEN AND CLOSED SUBROUTINES