proxy_pass:充当代理服务器,转发请求
proxy_redirect:修改301或者302转发过程中的Location。默认值为proxy_redirect default。

例:
location / {
              proxy_pass http://192.168.8.46:8080/; #/结尾
              #proxy_redirect default #此为默认值,加不加都一样。
         }
这样代理到其它机器的8080端口,访问的时候都没问题,
Location: http://192.168.8.46/haha4/,浏览器的url地址栏也是http://192.168.8.46/haha4/

若:
location / {
              proxy_pass http://192.168.8.46:8080;#去掉/
              proxy_redirect off #修改默认值default为off
         }
如果去掉最后的/以后,curl -I http://192.168.8.46/haha4 访问
Location: http://192.168.8.46:8080/haha4/
浏览器访问显示的地址栏为http://192.168.8.46:8080/haha4/,(如果还是之前的,需要先删缓存)
可以看到,真实的Location地址全部暴露出来的,这个时候就需要使用proxy_redirect修改这个Location
配置如下:
location / {
              proxy_pass http://192.168.8.46:8080;
             proxy_redirect http://192.168.8.46:8080/haha4/ http://192.168.8.46/haha4/;
         }
这样,就能修改Location的地址,Location: http://192.168.8.46/haha4/,在浏览器里也是如此,就不会暴露端口号等信息,
当然,你还可以把Location弄到其它网站上去,例如
proxy_redirect http://192.168.8.46:8080/haha4/ http://www.douban.com/;
然后浏览器就跳过去了。

总结:
一切幕后黑手就是
 proxy_pass http://192.168.8.46:8080; 不加/结尾,只要把/加上,proxy_redirect 用默认值就OK了。

nginx proxy_pass 和 proxy_redirect的更多相关文章

  1. nginx proxy_pass 指令

    nginx proxy_pass 指令 文档 Nginx 官方文档 https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pa ...

  2. nginx proxy_pass

    在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理 ...

  3. nginx proxy_pass 与 rewrite 简记

    rewrite syntax: rewrite regex replacement [flag] Default: - Context: server, location, if 如果正则表达式(re ...

  4. nginx proxy_pass 代理域名

    一.描述 1.nginx配置转发的时候使用的是域名,即使用dns服务方便配置和负载.但是nginx默认会进行缓存,当域名对应的服务出问题的时候就会报错,只有默认的缓存时间到了才会再次进行解析,ngin ...

  5. nginx proxy_pass指令’/’注意事项

    1. proxy_pass配置说明 不带/ location /test/ { proxy_pass http://t6:8300; } 带/ location /test/ { proxy_pass ...

  6. 用反向代理nginx proxy_pass配置解决ie8 ajax请求被拦截问题 ie8用nginx代理实现跨域请求访问 nginx405正向代理request_uri

    最近调PC版网站ie8的兼容性,发现所有ajax请求还没到后端服务器就直接ajax error了 ie8发不出ajax请求,断点调试发现ajax全进入了error,提示“No transport” 我 ...

  7. nginx proxy_pass后的url加不加/的区别

    在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走. 下面四种 ...

  8. NGINX proxy_pass 域名解析问题

    前两天发现一个问题,当使用proxy_pass的时候,发现域名对应IP是缓存的,这样一旦VIP变化之后,就会报错,下面就来详细分析一下这个问题. 一.问题说明 location = /test { i ...

  9. [nginx]proxy_pass&rewrite知识点

    While passing request nginx replaces URI part which corresponds to location with one indicated in pr ...

随机推荐

  1. [VINS]IMU与相机之间旋转量的标定

    VINS-Mono[1]中IMU-Camera外参旋转量\(R_b^c\)的计算方法在他们实验室发的之前的论文有详细讲解[2].视觉利用匹配特征点中的基础矩阵求出相机坐标系下两帧的旋转量\(R_{c_ ...

  2. WPF拖拽文件(拖入拖出),监控拖拽到哪个位置,类似百度网盘拖拽

    1.往wpf中拖文件 // xaml <Grid x:Name="grid_11" DragOver="Grid_11_DragOver" Drop=&q ...

  3. 解决PKIX path building failed的问题

    Java在请求某些不受信任的https网站时会报:PKIX path building failed 解决方法一:使用keytool手动导入证书,为JRE环境导入信任证书 参考:http://www. ...

  4. easyUI相关文件的引入

    引入以下内容: <head> <meta http-equiv="Content-Type" content="text/html; charset=u ...

  5. Nginx中配置https中引用http的问题

    Nginx中配置https中引用http的问题 遇到问题: 今天公司要在后台增加直播入口,使用腾讯云的实时音视频,要求是必须使用https,在配置完强制跳转https候,发现后台无法上传图片,在浏览器 ...

  6. Redis怎么做持久化

    1.redis持久化的两种方式 2.两种持久化方式区别 3.两种持久化方式的使用场景 1.Redis 是内存型数据库,一般来用作缓存.保存在内存的数据有一个特点, 就是断电消失,因此一旦 Redis ...

  7. SpringBoot项目优化和Jvm调优

    https://www.cnblogs.com/jpfss/p/9753215.html 项目调优 作为一名工程师,项目调优这事,是必须得熟练掌握的事情. 在SpringBoot项目中,调优主要通过配 ...

  8. phonetic

    Simple Classification of English Vowels and Consonants 1.Classifation of English Vowels a)Monophtong ...

  9. 算法学习 howto

    入门: The Most Important Algorithms http://www.risc.jku.at/people/ckoutsch/stuff/e_algorithms.html Alg ...

  10. Thymeleaf 整理

    1.标准变量表达式: thymeleaf中的变量表达式使用${变量名}的方式获取其中的数据 th:text="" 是thymeleaf的一个属性,用于文本的显示 如:<spa ...