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 //客 ...
随机推荐
- learning makefile automatic dependency generation
- python之路-----多线程与多进程
一.进程和线程的概念 1.进程(最小的资源单位): 进程:就是一个程序在一个数据集上的一次动态执行过程.进程一般由程序.数据集.进程控制块三部分组成. 程序:我们编写的程序用来描述进程要完成哪些功能以 ...
- FFT与一些冷门问题
FFT也能用于一些特殊的字符串匹配与最小化问题. Prob 1 : 给出模式串A与文本串B,两个串中只有26个大写字母与通配符'?'(即可以任意匹配一个字符),求A在B中的匹配数.要求以FFT为例给出 ...
- angular2升级到angular4历程
Angular 4 在昨天(2017-03-24)正式发布了,我的系列教程也得更新一下.步骤略繁琐,不用 cli 的项目反倒更简单一些,但是 cli 平时给我们的便利还是很多的,升级最多半年一次而已. ...
- lvs三种模式的优缺点对比
电面只回答上来少部分,所以......恶补.总结
- JavaScript 注意要点
何时加引号: 只有变量不加引号.加了引号的一定不是变量,是字符 方法: 方法一律带有小括号 js 中的作用域 全局变量: 在最外层定义的变量: 在函数体内部看是没有声明var的 也是全局 ...
- 自动化测试-18.selenium之bugFree代码注释
#encoding=utf-8 import xlrd,time,os from xlutils.copy import copy from selenium import webdriver def ...
- Lua IDE工具-Intellij IDEA+lua插件配置教程(Chianr出品)
Lua 编译工具IDE-Intellij IDEA 本文提供全流程,中文翻译. Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Ch ...
- 02bootstrap_通用标签样式和代码
---恢复内容开始--- 02bootstrap_通用标签样式和代码 1.标题:page-header 副标题样式 2.常用标签和样式 Bootstrap 将全局 font-size 设置为 14px ...
- PC timeline
https://news.microsoft.com/facts-about-microsoft/ 日期 事件 1975年 微软成立 1981年 ...