Skip to content

Commit

Permalink
add 详解Nginx-proxy_pass使用.md
Browse files Browse the repository at this point in the history
  • Loading branch information
yangpeng committed Mar 27, 2022
1 parent ecab4de commit d2a4262
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
56. [Mysqldump导入备份数据到阿里云RDS会报错吗](https://github.com/yangpeng14/DevOps/blob/master/ops/mysqldump%E5%AF%BC%E5%85%A5%E5%A4%87%E4%BB%BD%E6%95%B0%E6%8D%AE%E5%88%B0%E9%98%BF%E9%87%8C%E4%BA%91RDS%E4%BC%9A%E6%8A%A5%E9%94%99%E5%90%97.md)
57. [聊聊TPS、QPS、CPS概念和区别.md](https://github.com/yangpeng14/DevOps/blob/master/ops/%E8%81%8A%E8%81%8ATPS-QPS-CPS%E6%A6%82%E5%BF%B5%E5%92%8C%E5%8C%BA%E5%88%AB.md)
58. [聊聊alpine系统一些操作](https://github.com/yangpeng14/DevOps/blob/master/ops/%E8%81%8A%E8%81%8Aalpine%E7%B3%BB%E7%BB%9F%E4%B8%80%E4%BA%9B%E6%93%8D%E4%BD%9C.md)
59. [详解Nginx proxy_pass 使用]()

### 八、Podman知识
1. [Podman 会取代 Docker 吗?](https://github.com/yangpeng14/DevOps/blob/master/podman/podman%E4%BC%9A%E5%8F%96%E4%BB%A3docker%E5%90%97.md)
Expand Down
48 changes: 48 additions & 0 deletions ops/详解Nginx-proxy_pass使用.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
## 前言

日常不管是研发还是运维,都多少会使用`Nginx`服务,很多情况Nginx用于反向代理,那就离不开使用`proxy_pass`,有些同学会对 `proxy_pass` 转发代理时 `后面url加 /``后面url没有 /``后面url添加其它路由`等场景,不能很明白其中的意思,下面来聊聊这些分别代表什么意思。

## 详解

客户端请求 URL `https://172.16.1.1/hello/world.html`

### 第一种场景 后面url加 /

```bash
location /hello/ {
proxy_pass http://127.0.0.1/;
}
```

`结果`:代理到URL:http://127.0.0.1/world.html


### 第二种场景 后面url没有 /

```bash
location /hello/ {
proxy_pass http://127.0.0.1;
}
```

`结果`:代理到URL:http://127.0.0.1/hello/world.html

### 第三种场景 后面url添加其它路由,并且最后添加 /

```bash
location /hello/ {
proxy_pass http://127.0.0.1/test/;
}
```

`结果`:代理到URL:http://127.0.0.1/test/world.html

### 第四种场景 后面url添加其它路由,但最后没有添加 /

```bash
location /hello/ {
proxy_pass http://127.0.0.1/test;
}
```

`结果`:代理到URL:http://127.0.0.1/testworld.html

0 comments on commit d2a4262

Please sign in to comment.