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. ...
随机推荐
- dm8148 开发之---互斥量、条件量、枷锁、互斥枷锁
int OSA_semCreate(OSA_SemHndl *hndl, Uint32 maxCount, Uint32 initVal){ pthread_mutexattr_t mutex_att ...
- Java类载入器原理分析
一:Java虚拟机中能够安装多个类载入器,系统默认是三个基本的类载入器: Bootstrap ExtClassLoader AppClassLoader 类载入器也是Java类.由于其它Java类 ...
- Android开发:使用DialogFragment实现dialog自定义布局
使用DialogFragment实现dialog的自定义布局最大的好处是可以更好控制dialog的生命周期. TestFragment的代码: public class TestFragment ex ...
- PHP中mysql_fetch_row()、mysql_fetch_assoc()和mysql_fetch_array()的联系
总是记不住或者混淆mysql_fetch_row().mysql_fetch_assoc()和mysql_fetch_array()这三个函数的朋友们注意了,今天我在这里给大家总结一下他们之间的关系, ...
- ul和li弄的图片列表
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 解决asp.net中HTML中talbe的行高被内容撑的变高的问题
将asp.net页面中的如下语句: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...
- make tree install 目录树状结构工具安装
http://futeng.iteye.com/blog/2071867 http://zhou123.blog.51cto.com/4355617/1196415 wget ftp://mama.i ...
- JLable设置复制粘贴
final JLabel keyLable = new JLabel(key); keyLable.addMouseListener(new MouseAdapter() { @Override pu ...
- JavaScript数据结构与算法-散列练习
散列的实现 // 散列类 - 线性探测法 function HashTable () { this.table = new Array(137); this.values = []; this.sim ...
- 【DevExpress】 SearchLookUpEdit
一.属性的基本介绍: 绑定数据源: lookUpEdit.Properties.ValueMember = 实际要用的字段; //相当于Editvalue lookUpEdit.Propertie ...