nginx:
192.168.1.23作为nginx反向代理机器
目标机器192.168.1.5上部署一个8090端口的nginx [root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
} location /proxy/ {
proxy_pass http://192.168.1.5:8090/;
}
} 访问http://192.168.1.23/proxy/就会被代理到http://192.168.1.5:8090/, 浏览器的url是http://192.168.1.23/proxy/不变,
目标机器上无需存在proxy目录(curl http://192.168.1.23/proxy 可以发现是302,301重定向) 如果:proxy_pass配置的url后面不加"/"
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
} location /proxy/ {
proxy_pass http://192.168.1.5:8090;
}
} 那么访问http://192.168.1.23/proxy或http://192.168.1.23/proxy/,都会失败!
这样配置后,访问http://192.168.1.23/proxy/就会被反向代理到http://192.168.1.5:8090/proxy/,目标机必须有proxy目录

快速记忆:proxypass最后如果带 / ,则代理到目标机就没有location后面的目录,  不带 /  , 到目标机后携带location后面的目录,一起带过去了

nginx location proxy pass的更多相关文章

  1. Nginx代理proxy pass配置去除前缀

    使用Nginx做代理的时候,可以简单的直接把请求原封不动的转发给下一个服务. 比如,访问abc.com/appv2/a/b.html, 要求转发到localhost:8088/appv2/a/b.ht ...

  2. Nginx location wildcard

    Module ngx_http_core_modulehttps://nginx.org/en/docs/http/ngx_http_core_module.html#location locatio ...

  3. Nginx应用-Location路由反向代理及重写策略 请求转发-URL匹配规则 NGINX Reverse Proxy

    NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ ...

  4. nginx proxy pass redirects ignore port

    nginx proxy pass redirects ignore port $host in this order of precedence: host name from the request ...

  5. nginx Location配置总结(转)

    本文部分转自:http://cssor.com/nginx-location-configuration.html 一. 开头 语法规则: location [=|~|~*|^~] /uri/ { … ...

  6. How nginx "location if" works

    Nginx's if directive does have some weirdness in practice. And people may misuse it when they do not ...

  7. nginx之proxy、cache、upstream模块学习

    nginx之proxy反向代理模块: location ^~ /proxy_path/ { root "/www/html"; 这里没必要配置 index index.html; ...

  8. Nginx web proxy NFS服务

    1.nginx web 安装 配置 #systemctl stop firewalld #systemctl disabled firewalld #wget -O /etc/yum.repos.d/ ...

  9. nginx http proxy 正向代理

    配置 Nginx Http Proxy 代理服务器,与 [Squid] 功能一样,适用于正向代理 Http 网站. 一,Nginx 正向代理配置文件: server { resolver 8.8.8. ...

随机推荐

  1. redhat6.5安装ntfs-3g rpm来支持ntfs文件系统挂载

    linux安装ntfs-3g模块来支持ntfs文件系统挂载 所需包 fuse-2.9.3.tar.gz ntfs-3g_ntfsprogs-2011.4.12.tgz step1. 解压fuse-2. ...

  2. Android APK反编译就这么简单 具体解释

    在学习Android开发的过程你.你往往会去借鉴别人的应用是怎么开发的,那些美丽的动画和精致的布局可能会让你爱不释手,作为一个开发人员.你可能会非常想知道这些效果界面是怎么去实现的,这时,你便能够对改 ...

  3. asp.net网站底部的版权信息实现代码且可维护

    网站底部的版权信息在特殊情况还是比较重要的所以在实现的时候一定要尽可能的做到可维护性,接下来将介绍一些技巧可达到可维护效果,感兴趣的你可不要错过了哈 一个大网站页面很多,如果每个版权信息直接写在下面, ...

  4. caffe net 可视化工具,,层特征可视化

    1.只用网络在线结构绘制可视化网络模型 http://ethereon.github.io/netscope/#/editor 将对应的网络输入到里面,然后按shift+enter即可查看对应的网络结 ...

  5. 定位frame中的元素

    场景 处理frame需要用到2个方法,分别是switch_to_frame(name_or_id_or_frame_element)和switch_to_default_content() 如何理解这 ...

  6. Olya and Energy Drinks(bfs)

    D. Olya and Energy Drinks time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  7. git 中 A C D M R T U X 分别解释

    git 中 A C D M R T U X 分别解释 - CSDN博客 https://blog.csdn.net/adminyan/article/details/64922979 A: 你本地新增 ...

  8. <2013 12 01> 一篇很好的关于windows编程的入门指导(2013年末写的,比较前沿)

    我之前做了不少嵌入式开发,从单片机到ARM到RTOS到Linux等等,可以说走的是电气工程师的路线,对编程也是实用性的,跟计算机学院的科班套路不同.最近同学做一个windowsCE的项目请我帮忙,之前 ...

  9. SQL 排序的N种方法

    一.手工查询得出名次 select * ,select count(*)+1 from T2 where T2.[成绩] > T1.[成绩] as 名次 from T1 结果:  1 2 3 3 ...

  10. Python3.6全栈开发实例[024]

    24.文件a1.txt内容(注意每行中的空格是不一样的,需要对空格进行处理)序号 部门   人数   平均年龄           备注 1 python   30   26   单身狗 2 Linu ...