NGINX配置之二: nginx location proxy_pass 后面的url 加与不加/的区别.
这里我们分4种情况讨论
这里我们请求的网站为:192.168.1.123:80/static/a.html
整个配置文件是
server{
port 80,
server name 192.168.1.123
location /static{
proxy_pass 192.168.2.321:81
}
location /static{
proxy_pass 192.168.2.321:81/
}
location /static/{
proxy_pass 192.168.2.321:81
}
location /static/{
proxy_pass 192.168.2.321:81/
}
我们分开来讲:
第一种:
location后没有/ 转发网站没有/
#192.168.1.123->server name
# :80 ---------> port
#/statc ------->location
#/a.html ------>proxy_pass location /static{
proxy_pass 192.168.2.321:81
}
最后网址经过nginx转向到的网址是 192.168.2.321:81/static/a.html
第二种:
location后没有/ 转发网站有/
#192.168.1.123---->server name
# :80 ------------> port
#/statc ---------->location
#/a.html --------->proxy_pass location /static{
proxy_pass 192.168.2.321:81/
}
最后网址经过nginx转向到的网址是 192.168.2.321:81/a.html 第三种:
location后有/ 转发网站没有/
#192.168.1.123-->server name
# :80 ------------> port
#/statc/ ---------->location
#a.html --------->proxy_pass location /static/{
proxy_pass 192.168.2.321:81
}
最后网址经过nginx转向到的网址是 192.168.2.321:81/static/a.html
第四种:
location后有/ 转发网站有/
#192.168.1.123-->server name
# :80 ------------> port
#/statc/ ---------->location(path1)
#a.html --------->proxy_pass (path2) location /static/{
proxy_pass 192.168.2.321:81/
}
最后网址经过nginx转向到的网址是 192.168.2.321:81/a.html
总结:
从这四种我们可以的看出,当nginx里面匹配时可以把端口后的参数分为path1+path2(其中我在上方标注的location属于path1,proxy_pass属于path2)
当
proxy_pass
里面是ip:port+/时nginx最后匹配的网址是 proxy_pass的内容加上path2
里面是ip:port时nginx最后匹配的网址是 proxy_pass的内容加上path1+path2
NGINX配置之二: nginx location proxy_pass 后面的url 加与不加/的区别.的更多相关文章
- nginx location proxy_pass 后面的url 加与不加/的区别
在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走. 首先是l ...
- nginx proxy_pass后的url加不加/的区别
在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走. 下面四种 ...
- nginx配置后端映射(反向代理proxy_pass)
说明:配置反向代理proxy_pass和location无关,location后面加不加 / 都可以 1.配置 proxy_pass 时,当在后面的 url 加上了 /,相当于是绝对路径,则 Ngin ...
- nginx 配置重定向及nginx配置if
需求:地址 http://testa/inlinePreview/live.html?id=463738305721405440重定向到 http://testb/shares/live.html?n ...
- Nginx阅读笔记(二)之location的用法
两个配置文件 一: server { listen 80; # # 在本机所有ip上监听80,也可以写为192.168.1.202:80,这样的话,就只监听192.168.1.202上的80口 ser ...
- nginx配置:支持phpfastcgi,nginx和php-cgi通信,部分nginx常量解释
支持phpfastcgi的配置如下: server { listen 8000; server_name localhost; root F:/home/projects/test; i ...
- nginx配置:支持phpfastcgi,nginx和php-cgi通信,部分nginx常量解释
支持phpfastcgi的配置如下: server { listen 8000; server_name localhost; root F:/home/projects/test; index in ...
- Nginx反向代理新篇-使用location对多个URL做反向代理
1.原理 Nginx解析location/后面的字符串,配置不同的字符串匹配不同的URL进行反向代理. 2.nginx.conf配置文件 worker_processes 1; events { wo ...
- Nginx配置Awstats分析Nginx日志笔记
1.修改Nginx日志格式: log_format json '$remote_addr - $remote_user [$time_local] "$request" ' ...
随机推荐
- 【ABAP系列】SAP ABAP 物料凭证增强
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 物料凭证增强 ...
- 剑指offer第二版面试题5:从尾到头打印链表(JAVA版)
题目描述: 输入一个链表,从尾到头打印链表每个节点的值.返回新链表. import java.util.Stack; //定义链表结构 class ListNode { int value; List ...
- SEC5 - MySQL 查询语句--------------进阶1:基础查询
# 进阶1:基础查询 /* 语法: select 查询列表 from 表名: 特点: 1.查询列表可以是:表中的字段.常量值.表达式.表达式.函数 2.查询的结果是一个虚拟的表格 如何执行:执行谁,请 ...
- 全文搜索 ElasticSearch
今天突然想了解一下ES,看看有什么优势,能不能用在项目中. 说到ES就不得不了解它的底层技术-全文检索 Ref: 全文检索的基本原理 https://blog.csdn.net/wangmaohong ...
- Content-Based Recommender System
Content-Based Recommender System是基于产品(商品.网页)的内容.属性.关键字,以及目标用户的喜好.行为,这两部分数据来联合计算出,该为目标用户推荐其可能最感兴趣的产品. ...
- 20190814 On Java8 第三章 万物皆对象
第三章 万物皆对象 对象创建 数据存储 有5个不同的地方可以存储数据: 寄存器 (Registers) 最快的存储区域,位于CPU内部 .无法直接控制. 栈内存(Stack) 存在于常规内存 RAM ...
- 移动app云测试平台
一:移动App云测试平台 1.云测试平台背景 随着智能手机的普及率和渗透率越来越高,App开发软件也越来越多.但是因为安卓和IOS的碎片化,尤其是安卓,因为完全开源的原因,导致设备繁多,品牌众多,版本 ...
- mysql 5.7 创建函数报错,This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creat
今天用命令创建函数, 报错 This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration ...
- 并行开发 1.Parallel
原文:8天玩转并行开发——第一天 Parallel的使用 随着多核时代的到来,并行开发越来越展示出它的强大威力,像我们这样的码农再也不用过多的关注底层线程的实现和手工控制, 要了解并行开发,需要先了解 ...
- iviewUI框架,使用table表格内render下拉框select被遮盖问题
使用props:{ transfer:true },即可 1.原本代码: