nginx的proxy_pass路径转发规则最后带/问题
一、location匹配路径末尾没有 /
location /sta
{
proxy_pass http://192.168.1.1/sta;
}
外面访问:http://外网IP/sta/sta1.html
相当于访问:http://192.168.1.1/sta/sta1.html
二、location匹配路径末尾有 /
此时proxy_pass后面的路径需要分为以下四种情况讨论:
(1)proxy_pass后面的路径只有域名且最后没有 /
location /sta/
{
proxy_pass http://192.168.1.1;
}
外面访问:http://外网IP/sta/sta1.html
相当于访问:http://192.168.1.1/sta/sta1.html
(2)proxy_pass后面的路径只有域名同时最后有 /
location /sta/
{
proxy_pass http://192.168.1.1/;
}
外面访问:http://外网IP/sta/sta1.html
相当于访问:http://192.168.1.1/sta1.html
(3)proxy_pass后面的路径还有其他路径但是最后没有 /:
location /sta/
{
proxy_pass http://192.168.1.1/abc;
}
外面访问:http://外网IP/sta/sta1.html
相当于访问:http://192.168.1.1/abcsta1.html
(4)proxy_pass后面的路径还有其他路径同时最后有 /:
location /sta/
{
proxy_pass http://192.168.1.1/abc/;
}
外面访问:http://外网IP/sta/sta1.html
相当于访问:http://192.168.1.1/abc/sta1.html
nginx的proxy_pass路径转发规则最后带/问题的更多相关文章
- nginx的proxy_pass路径转发规则浅析(末尾/问题)
源地址 : https://www.zifangsky.cn/917.html 一 location匹配路径末尾没有 / 此时proxy_pass后面的路径必须拼接location的路径: 1 2 ...
- Nginx配置proxy_pass转发的/路径问题
Nginx配置proxy_pass转发的/路径问题 在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则 ...
- 用haproxy实现nginx的proxy_pass转发功能
公司的网站有个需求,主站点上有两个URL,没有在本地nginx上配置,而是在另一台主机的nginx上配置的站点.如果使用nginx作为反向代理,可以使用proxy_pass指令转发对这两个URL的请求 ...
- Nginx location 和 proxy_pass路径配置详解
目录 一.Nginx location 基本配置 1.1.Nginx 配置文件 1.2 .Python 脚本 二.测试 2.1.测试 location 末尾存在 / 和 proxy_pass末尾存在 ...
- (转)nginx做转发时,带'_'的header内容丢失
原本在测试环境测试通过的APP,今天准备切到线上环境做最后测试,结果发现了错误.查看日志发现是APP端发送的http请求中的header内容丢失了.那么代码没有改动,怎么平白无故会丢失头信息? 于是想 ...
- Nginx配置location及rewrite规则
Nginx配置location及rewrite规则 示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } loca ...
- Nginx配置proxy_pass
nginx配置proxy_pass,需要注意转发的路径配置 1.location /test/ { proxy_pass http://t6:8300; } 2.location /test/ { p ...
- nginx 之 proxy_pass
nginx中有两个模块都有proxy_pass指令 ngx_http_proxy_module的proxy_pass 语法: proxy_pass URL; 场景: location, if in l ...
- Nginx 常用全局变量 及Rewrite规则详解
每次都很容易忘记Nginx的变量,下面列出来了一些常用 $remote_addr //获取客户端ip $binary_remote_addr //客户端ip(二进制) $remote_port //客 ...
随机推荐
- Charles设置HTTPS抓包
1. 配置 Charles 根证书 点击 Help -> SSL Proxying -> Install Charles Root Certificate 之后会弹出钥匙串,如果不弹出,请 ...
- tf 随机数
tf生成随机数 import tensorflow as tf sess = tf.InteractiveSession() ### 生成符合正态分布的随机值 # tf.random_normal(s ...
- RockeMq源码之Client
Client中既有producer,也有consumer,先看前者 org.apache.rocketmq.client.producer.DefaultMQProducer.class 一般都是调用 ...
- c++结构体的排序
出处:https://blog.csdn.net/weixin_39460667/article/details/82695190 引入头文件 #include<algorithm> 结构 ...
- phpcms 加载微信类库,生成签名
在phpcms 中 pc_base:load_config(文件名) 用于加载配置文件,配置文件存放于phpcms目录下的caches/configs中 在控制器新增加载微信类库的方法: /** * ...
- 负载均衡集群相关、LVS介绍、LVS调度算法、LVS NAT模式搭建
1.负载均衡集群相关 2.LVS的三种模式:NAT.DR .IP tunnel 3. LVS的调度算法(共有8种) 4.LVS NAT模式搭建准备条件: 在分发服务器上安装:yum install ...
- 面向对象+JAVA基础
泛泛的研究了面向对象的前五章,感觉没有代码的参照理解的知识看过就忘,所以又在推荐下开始了JAVA基础,希望不会鄙视我目前么有一本书能完整看完的记录... public class LeapYear { ...
- java初始重点语法
第三章 if基本语法: if(条件){// 表达式 // 代码块 } eg: int a = 10; if(a > 1){ System.out.println("内容"); ...
- 为什么redis使用单线程还能这么快?
通常来讲,单线程处理能力要比多线程差,但是redis为什么就快了,这主要得益于以下几个原因: 1.纯内存访问,redis将所有数据放在内存中,内存的响应时长大约为100纳秒,这是redis达到每秒万级 ...
- 二十一、springcloud(七)服务网关zuul
1.简介 Eureka用于服务的注册于发现,Feign支持服务的调用以及均衡负载,Hystrix处理服务的熔断防止故障扩散,Spring Cloud Config服务集群配置中心,在微服务架构中,后端 ...