nginx location proxy pass
nginx:
192.168.1.23作为nginx反向代理机器
目标机器192.168.1.5上部署一个8090端口的nginx [root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
} location /proxy/ {
proxy_pass http://192.168.1.5:8090/;
}
} 访问http://192.168.1.23/proxy/就会被代理到http://192.168.1.5:8090/, 浏览器的url是http://192.168.1.23/proxy/不变,
目标机器上无需存在proxy目录(curl http://192.168.1.23/proxy 可以发现是302,301重定向) 如果:proxy_pass配置的url后面不加"/"
[root@localhost conf.d]# cat test.conf
server {
listen 80;
server_name localhost;
location / {
root /var/www/html;
index index.html;
} location /proxy/ {
proxy_pass http://192.168.1.5:8090;
}
} 那么访问http://192.168.1.23/proxy或http://192.168.1.23/proxy/,都会失败!
这样配置后,访问http://192.168.1.23/proxy/就会被反向代理到http://192.168.1.5:8090/proxy/,目标机必须有proxy目录
快速记忆:proxypass最后如果带 / ,则代理到目标机就没有location后面的目录, 不带 / , 到目标机后携带location后面的目录,一起带过去了
nginx location proxy pass的更多相关文章
- Nginx代理proxy pass配置去除前缀
使用Nginx做代理的时候,可以简单的直接把请求原封不动的转发给下一个服务. 比如,访问abc.com/appv2/a/b.html, 要求转发到localhost:8088/appv2/a/b.ht ...
- Nginx location wildcard
Module ngx_http_core_modulehttps://nginx.org/en/docs/http/ngx_http_core_module.html#location locatio ...
- Nginx应用-Location路由反向代理及重写策略 请求转发-URL匹配规则 NGINX Reverse Proxy
NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ ...
- nginx proxy pass redirects ignore port
nginx proxy pass redirects ignore port $host in this order of precedence: host name from the request ...
- nginx Location配置总结(转)
本文部分转自:http://cssor.com/nginx-location-configuration.html 一. 开头 语法规则: location [=|~|~*|^~] /uri/ { … ...
- How nginx "location if" works
Nginx's if directive does have some weirdness in practice. And people may misuse it when they do not ...
- nginx之proxy、cache、upstream模块学习
nginx之proxy反向代理模块: location ^~ /proxy_path/ { root "/www/html"; 这里没必要配置 index index.html; ...
- Nginx web proxy NFS服务
1.nginx web 安装 配置 #systemctl stop firewalld #systemctl disabled firewalld #wget -O /etc/yum.repos.d/ ...
- nginx http proxy 正向代理
配置 Nginx Http Proxy 代理服务器,与 [Squid] 功能一样,适用于正向代理 Http 网站. 一,Nginx 正向代理配置文件: server { resolver 8.8.8. ...
随机推荐
- 在Amazon cloud 升级CentOS5.4 到 5.9
升级前一定要备份重要资料,做好最坏的打算,最好的准备! 老板不知道为什么,喜欢升级服务器,劝过好几次都坚持要升级. 好吧,you are boss. 升级前当然免不了google一番.发现CentOS ...
- Laravel中创建控制器
<?php /** * Created by PhpStorm. * User: chuang * Date: 17-1-14 * Time: 下午4:29 */ namespace App\H ...
- Laravel 的中大型专案架构
好文:http://oomusou.io/laravel/laravel-architecture/
- pycharn设置git提交代码
1.设置pycharm的git地址 2.设置git地址及本地路径 3.提交代码
- Java 基础巩固:IO
在学习IO的时候发现IO的类太多,如InputStream下面就用ReaderInputStream.InputStreamBuffer等等, 还用Reader.Writer.OutputStream ...
- splay tree成段更新,成段查询poj3466
线段树入门题,换成splay tree 来搞搞. #include <stdio.h> #include <string.h> #include <algorithm&g ...
- 七、Dockerfile案例一(jdk1.8安装)
七.Dockerfile案例一(jdk1.8安装) 1 获取一个简单的Docker系统镜像,并建立一个容器. 这里我选择下载CentOS镜像 docker pull centos 通过docker t ...
- 项目中调用ExcelCom组件时的配置流程
异常提示如下: Microsoft Office Excel 不能访问文件“*.xls”. 可能的原因有: 1 文件名称或路径不存在. 2 文件正被其他程序使 ...
- iOS 横竖屏适配
关于横竖屏适配 也没做过,今天读别人的源码,遇到了.为了了解清楚,就系统的学习一下. 一 横竖屏方向枚举 关于横竖屏一共有三种枚举 UIInterfaceOrientation UIInterface ...
- PHP7-MySQLi在分页中的应用
获取页码,设置每页行数 $page = $_POST["page"]; if($page == ""||$page <= 0){ $page = 1; } ...