nginx location proxy pass
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的更多相关文章
- Nginx代理proxy pass配置去除前缀
使用Nginx做代理的时候,可以简单的直接把请求原封不动的转发给下一个服务. 比如,访问abc.com/appv2/a/b.html, 要求转发到localhost:8088/appv2/a/b.ht ...
- Nginx location wildcard
Module ngx_http_core_modulehttps://nginx.org/en/docs/http/ngx_http_core_module.html#location locatio ...
- Nginx应用-Location路由反向代理及重写策略 请求转发-URL匹配规则 NGINX Reverse Proxy
NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ ...
- nginx proxy pass redirects ignore port
nginx proxy pass redirects ignore port $host in this order of precedence: host name from the request ...
- nginx Location配置总结(转)
本文部分转自:http://cssor.com/nginx-location-configuration.html 一. 开头 语法规则: location [=|~|~*|^~] /uri/ { … ...
- How nginx "location if" works
Nginx's if directive does have some weirdness in practice. And people may misuse it when they do not ...
- nginx之proxy、cache、upstream模块学习
nginx之proxy反向代理模块: location ^~ /proxy_path/ { root "/www/html"; 这里没必要配置 index index.html; ...
- Nginx web proxy NFS服务
1.nginx web 安装 配置 #systemctl stop firewalld #systemctl disabled firewalld #wget -O /etc/yum.repos.d/ ...
- nginx http proxy 正向代理
配置 Nginx Http Proxy 代理服务器,与 [Squid] 功能一样,适用于正向代理 Http 网站. 一,Nginx 正向代理配置文件: server { resolver 8.8.8. ...
随机推荐
- python 面试题 string int
str1 = 'hello' str2 = str1 str3 = str1 str4 = str1 str1 = '' int1 = 1 int2 = int1 int3 = int1 int4 = ...
- window linux IPC ftok BY_HANDLE_FILE_INFORMATION
看这题目就很乱,心情当然也是不怎么美好了.前一段时间做了一个项目,AIX(Unix的一种)中的一个系统向WINDOWS移植,开发环境由IBM的C/C++(叫什么忘记了,好像是xlC)变为VC++. 这 ...
- ROS导航之地图costmap_2d与bresenham算法
读者可以参读http://wiki.ros.org/costmap_2d costmap_2d: 无论是激光雷达还是如kinect 或xtion pro深度相机作为传感器跑出的2D或3D SLAM ...
- Tesseract–OCR 库原理探索
一,简介: Tesseract is probably the most accurate open source OCR engine available. Combined with the Le ...
- shell编程实战总结
最近复习一下shell,顺便高级进阶一下,之前写脚本能简单尽量简单来,发现好多高深的东西还是没有理解,因此在这里记录一下整个过程并做相应的总结. 通过上代码的方式来介绍,后续可能会调整相应的排版 1. ...
- Unity3d 子线程能做的事
一,子线程中能做的事: 1,数据逻辑方面计算: 二,子线程中,不能: 1,加载场景相关事件: Application.LoadLevelAsync.Application.LoadLevel等: 2, ...
- 使用MyBatis_Generator工具jar包自动化生成Dto、Dao、Mapping 文件
由于MyBatis属于一种半自动的ORM框架,所以主要的工作将是书写Mapping映射文件,但是由于手写映射文件很容易出错,所以查资料发现有现成的工具可以自动生成底层模型类.Dao接口类甚至Mappi ...
- JS HTML DOM---Document对象
Document 对象 当浏览器载入 HTML 文档, 它就会成为 document 对象. document 对象是HTML文档的根节点与所有其他节点(元素节点,文本节点,属性节点, 注释节点). ...
- Ramsey's_theorem Friendship Theorem 友谊定理
w https://en.wikipedia.org/wiki/Ramsey's_theorem https://zh.wikipedia.org/wiki/拉姆齐定理 在组合数学上,拉姆齐(Rams ...
- Vue父组件调用子组件的方法
vue中如果父组件想调用子组件的方法,可以在子组件中加上ref,然后通过this.$refs.ref.method调用,例如: 父组件: <template> <div @click ...