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 //客 ...
随机推荐
- 版本管理工具Git(3)VS2013下如何使用git
Git系列导航 版本管理工具Git(1)带你认识git 版本管理工具Git(2)git的安装及使用 版本管理工具Git(3)VS下如何使用git VS下创建项目 vs中新建项目MyGitTest201 ...
- 3D打印GCODE文件学习(一)
我家有一个天威的入门级的3D打印机.它有一个配套的软件叫“Rrint-RiteCoLiDo Repetier-Host V1.5.5”,用来连接.控制打印机.同时它可以加载各种切片软件,对各种3D模型 ...
- 架构之路:nginx与IIS服务器搭建集群实现负载均衡(二)
[前言] 在<架构之路:nginx与IIS服务器搭建集群实现负载均衡(一)>中小编简单的讲解了Nginx的原理!俗话说:光说不练假把式.接下来,小编就和大家一起来做个小Demo来体会一下N ...
- PXE 实现自动装机
搭建 PXE 远程安装服务器 image_1cqg00g0os9b1pop122e98o19ef9b.png-255kB 1.把光盘源放在/var/ftp/centos6 因为远程装机对放服务器得读取 ...
- redis缓存工具类
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis ...
- Java基础-方法
方法 Java方法是语句的集合,它们在一起执行一个功能. 方法是解决一类问题的步骤的有序组合 方法包含于类或对象中 方法在程序中被创建,在其他地方被引用 注意: 在一些其它语言中方法指过程和函数.一个 ...
- Building tools 为什么是主流?
一.building tools 为什么主流? Gradle 是目前比较流行的构建工具之一,Android Studio 中集成的就是 Gradle,并针对 Android 应用开发了插件 Gradl ...
- postman之如何获取cookie
1.最近在学习postman的使用方法,为了保证后续模块操作,必须在登录时获取的session值,并将其设置为环境变量,session的位置处于response headers里面返回的set-coo ...
- jenkins 持续集成iOS开发
持续集成即Continuous Integration,简称CI 1,安装jenkins,brew install jenkins 2,在浏览器输入localhost:8080会出现一个网页,要求输入 ...
- linux c 输出信息到console
static void console_log(const char *format, ...) { static FILE *fpConsole; if (fpConsole == NULL) { ...