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" ' ...
随机推荐
- 【MM系列】SAP ABAP 在选择画面显示输出结果
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 在选择画面显示 ...
- out.write()和out.print()区别,jsp注释区别
out.write()和out.print()结果一样,都是输出内容 前者输出html内容 后者输出变量 5 JSP注释 我们现在已经知道JSP是需要先编译成.java,再编译成.class的.其中& ...
- 基于Select模型的Windows TCP服务端和客户端程序示例
最近跟着刘远东老师的<C++百万并发网络通信引擎架构与实现(服务端.客户端.跨平台)>,Bilibili视频地址为C++百万并发网络通信引擎架构与实现(服务端.客户端.跨平台),重新复习下 ...
- java8新特性-简介
一.主要内容 :其中最为核心的为lambda 表达式 与 Stream API lambda表达式 函数式接口 方法引用与构造器引用 Stream API 接口中的默认方法与静态方法 新时间日期API ...
- spring-第二篇ApplicationContext国际化及事件机制
1.ApplicationContext接口获取spring容器 ApplicationContext是BeanFactory接口的子接口,BeanFactory的常用实现类是Default ...
- Codeforces 1082D (贪心)
题面 传送门 分析 贪心 将度限制大于1的点连成一条链,然后将度限制等于1的点挂上去 形状如下图,其中(1,2,3)为度数限制>1的点 显然直径长度=(度数限制>1的节点个数)-1+min ...
- [转载]Redux原理(一):Store实现分析
写在前面 写React也有段时间了,一直也是用Redux管理数据流,最近正好有时间分析下源码,一方面希望对Redux有一些理论上的认识:另一方面也学习下框架编程的思维方式. Redux如何管理stat ...
- 2019-6-23-WPF-托盘显示
title author date CreateTime categories WPF 托盘显示 lindexi 2019-06-23 11:52:36 +0800 2018-11-21 11:19: ...
- (ACM模板)集合set
#include<iostream> #include<cstdio> #include<set> using namespace std; int main() ...
- yara规则的二进制漏洞
https://www.anquanke.com/post/id/147675 yara32.exe 后缀.yar