1. nginx:
  2. 192.168.1.23作为nginx反向代理机器
  3. 目标机器192.168.1.5上部署一个8090端口的nginx
  4.  
  5. [root@localhost conf.d]# cat test.conf
  6. server {
  7. listen 80;
  8. server_name localhost;
  9. location / {
  10. root /var/www/html;
  11. index index.html;
  12. }
  13.  
  14. location /proxy/ {
  15. proxy_pass http://192.168.1.5:8090/;
  16. }
  17. }
  18.  
  19. 访问http://192.168.1.23/proxy/就会被代理到http://192.168.1.5:8090/, 浏览器的url是http://192.168.1.23/proxy/不变,
  20. 目标机器上无需存在proxy目录(curl http://192.168.1.23/proxy 可以发现是302,301重定向)
  21.  
  22. 如果:proxy_pass配置的url后面不加"/"
  23. [root@localhost conf.d]# cat test.conf
  24. server {
  25. listen 80;
  26. server_name localhost;
  27. location / {
  28. root /var/www/html;
  29. index index.html;
  30. }
  31.  
  32. location /proxy/ {
  33. proxy_pass http://192.168.1.5:8090;
  34. }
  35. }
  36.  
  37. 那么访问http://192.168.1.23/proxy或http://192.168.1.23/proxy/,都会失败!
  38. 这样配置后,访问http://192.168.1.23/proxy/就会被反向代理到http://192.168.1.5:8090/proxy/,目标机必须有proxy目录

快速记忆:proxypass最后如果带 / ,则代理到目标机就没有location后面的目录,  不带 /  , 到目标机后携带location后面的目录,一起带过去了

nginx location proxy pass的更多相关文章

  1. Nginx代理proxy pass配置去除前缀

    使用Nginx做代理的时候,可以简单的直接把请求原封不动的转发给下一个服务. 比如,访问abc.com/appv2/a/b.html, 要求转发到localhost:8088/appv2/a/b.ht ...

  2. Nginx location wildcard

    Module ngx_http_core_modulehttps://nginx.org/en/docs/http/ngx_http_core_module.html#location locatio ...

  3. Nginx应用-Location路由反向代理及重写策略 请求转发-URL匹配规则 NGINX Reverse Proxy

    NGINX Docs | NGINX Reverse Proxy https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ ...

  4. nginx proxy pass redirects ignore port

    nginx proxy pass redirects ignore port $host in this order of precedence: host name from the request ...

  5. nginx Location配置总结(转)

    本文部分转自:http://cssor.com/nginx-location-configuration.html 一. 开头 语法规则: location [=|~|~*|^~] /uri/ { … ...

  6. How nginx "location if" works

    Nginx's if directive does have some weirdness in practice. And people may misuse it when they do not ...

  7. nginx之proxy、cache、upstream模块学习

    nginx之proxy反向代理模块: location ^~ /proxy_path/ { root "/www/html"; 这里没必要配置 index index.html; ...

  8. Nginx web proxy NFS服务

    1.nginx web 安装 配置 #systemctl stop firewalld #systemctl disabled firewalld #wget -O /etc/yum.repos.d/ ...

  9. nginx http proxy 正向代理

    配置 Nginx Http Proxy 代理服务器,与 [Squid] 功能一样,适用于正向代理 Http 网站. 一,Nginx 正向代理配置文件: server { resolver 8.8.8. ...

随机推荐

  1. dm8148 开发之---互斥量、条件量、枷锁、互斥枷锁

    int OSA_semCreate(OSA_SemHndl *hndl, Uint32 maxCount, Uint32 initVal){ pthread_mutexattr_t mutex_att ...

  2. Java类载入器原理分析

    一:Java虚拟机中能够安装多个类载入器,系统默认是三个基本的类载入器: Bootstrap  ExtClassLoader  AppClassLoader 类载入器也是Java类.由于其它Java类 ...

  3. Android开发:使用DialogFragment实现dialog自定义布局

    使用DialogFragment实现dialog的自定义布局最大的好处是可以更好控制dialog的生命周期. TestFragment的代码: public class TestFragment ex ...

  4. PHP中mysql_fetch_row()、mysql_fetch_assoc()和mysql_fetch_array()的联系

    总是记不住或者混淆mysql_fetch_row().mysql_fetch_assoc()和mysql_fetch_array()这三个函数的朋友们注意了,今天我在这里给大家总结一下他们之间的关系, ...

  5. ul和li弄的图片列表

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. 解决asp.net中HTML中talbe的行高被内容撑的变高的问题

    将asp.net页面中的如下语句: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...

  7. make tree install 目录树状结构工具安装

    http://futeng.iteye.com/blog/2071867 http://zhou123.blog.51cto.com/4355617/1196415 wget ftp://mama.i ...

  8. JLable设置复制粘贴

    final JLabel keyLable = new JLabel(key); keyLable.addMouseListener(new MouseAdapter() { @Override pu ...

  9. JavaScript数据结构与算法-散列练习

    散列的实现 // 散列类 - 线性探测法 function HashTable () { this.table = new Array(137); this.values = []; this.sim ...

  10. 【DevExpress】 SearchLookUpEdit

    一.属性的基本介绍: 绑定数据源: lookUpEdit.Properties.ValueMember = 实际要用的字段;   //相当于Editvalue lookUpEdit.Propertie ...