请求原地址 :http://servername/static_js/test.html

location ^~ /static_js/
{
proxy_cache js_cache;
proxy_set_header Host js.test.com;
proxy_pass http://js.test.com/;
} 或者 使用rewrite location ^~ /static_js/ 

proxy_cache js_cache; 
proxy_set_header Host js.test.com; 
rewrite /static_js/(.+)$ /$1 break; 
proxy_pass http://js.test.com

代理成 http://js.test.com/test.html

location ^~ /static_js/
{
proxy_cache js_cache;
proxy_set_header Host js.test.com;
proxy_pass http://js.test.com;
}

代理成 http://js.test.com/static_js/test.htm

域名跳转 访问 crm6yy_proxy.xxx.com    跳转到  crm6yy.xxx.com

 server {

        listen 80  ;
server_name crm6yy_proxy.xxx.com;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://crm6yy.xxx.com/;
}
}

  正向代理

场景

A 不能上外网

B 能上外网 (A和B可以互相访问)

C 外面的网站 http://www.baidu.com

B上nginx配置如下代码

resolver 8.8.8.8;
server {
listen ; location / {
proxy_pass $scheme://$http_host$request_uri;
}
}

使用:

在A机器访问:

或者 curl -x B:8090 -k "C"

或者 export http_proxy="http://B:8090"

或者windows下:在internet选项->连接->局域网设置->代理服务器 填入ip及端口即可

Nginx配置proxy_pass转发的/路径的更多相关文章

  1. Nginx配置proxy_pass转发的/路径问题

    Nginx配置proxy_pass转发的/路径问题 在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/,当加上了/,相当于是绝对根路径,则 ...

  2. Nginx配置proxy_pass转发/路径问题

    proxy_ignore_client_abort on; #不允许代理端主动关闭连接 upstream的负载均衡,四种调度算法 #调度算法1:轮询.每个请求按时间顺序逐一分配到不同的后端服务器,如果 ...

  3. Nginx配置proxy_pass

    nginx配置proxy_pass,需要注意转发的路径配置 1.location /test/ { proxy_pass http://t6:8300; } 2.location /test/ { p ...

  4. 记录一次 Nginx 配置 proxy_pass 后 返回404问题

    一. Nginx 配置 proxy_pass 后 返回404问题 故障解决和定位 1.1. 问题 在一次生产涉及多次转发的配置中, 需求是下面的图: 在配置好了 proxy_pass 之后,请求 ww ...

  5. nginx配置https转发到tomcat(使用自签名的证书)

    一.使用openSSL生成自签名的证书 1.生成RSA私钥 命令:openssl genrsa -des3 -out server.key 1024 说明:生成rsa私钥,des3算法,1024强度, ...

  6. Nginx配置域名转发实例

    域名:cps.45wan.com   所在阿里云主机:123.35.9.12 45wan没有在阿里云备案 67wan已经在阿里云备案 阿里云主机(假如123.35.9.12)上原来的nginx配置: ...

  7. Nginx配置proxy_pass【转载】

    在nginx中配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走;如果没有/,则会把匹配的路径部分也给代理走. 下面四种 ...

  8. nginx 配置proxy_pass URL末尾加与不加/(斜线)的区别

    nginx在配置proxy_pass的时候 URL结尾加斜线(/)与不加的区别和注意事项 假设访问路径的 /pss/bill.html 加/斜线的情况 location /pss/ { proxy_p ...

  9. nginx配置proxy_pass URL末尾加与不加/(斜线)的区别

    nginx在配置proxy_pass的时候 URL结尾加斜线(/)与不加的区别和注意事项 假设访问路径的 /pss/bill.html 加/斜线的情况 location /pss/ { proxy_p ...

随机推荐

  1. vue - 路由传递参数

    结构目录 1. 页面传值(不同之间的页面传值) 1.1 index.js配置 源码: // 引入vue框架 import Vue from 'vue' // 引入vue-router路由依赖 impo ...

  2. PHP Libxml函数

    PHP Libxml 函数 PHP Libxml 简介 Libxml 函数和常量与 SimpleXML.XSLT 以及 DOM 函数一起使用. 安装 这些函数需要 Libxml 程序包. 在 xmls ...

  3. Unity发布各平台路径

    #if UNITY_EDITOR string filepath = Application.dataPath + "/StreamingAssets"; #elif UNITY_ ...

  4. postgres时间转换函数

    函数 返回类型 描述 例子 to_char(timestamp, text) text 把时间戳转换成字串 to_char(current_timestamp, 'HH12:MI:SS') to_ch ...

  5. java注解,通过反射解析注解,模仿hibernate,获取sql语句。

    常用注解: 自定义注解,标准格式: 1,target:注解作用域 2,Retention:声明周期 运行子类继承,但是子类继承只能作用到类注解,字段注解,是继承不了的. 使用注解:通过下面这种方式,为 ...

  6. android中RecycleView分页原生代码封装,无任何第三方代

    概述 RecycleView分页加载封装,简单方便,功能齐全 详细 代码下载:http://www.demodashi.com/demo/13283.html 一.场景: 在项目开发中经常使用到列表集 ...

  7. AFNetworking2.0源代码解析

    写在前面给大家推荐一个不错的站点 点击打开链接 本文測试样例源代码下载地址 近期看AFNetworking2的源代码.学习这个知名网络框架的实现.顺便梳理写下文章. AFNetworking的代码还在 ...

  8. Mybatis-Generator自动生成代码

    在使用mybatis开发的过程中,通常我们会给数据库的每张表编写对应的model.dao.mapping,虽然很简单,但是工作量很大,所以通常会使用代码生成器Mybatis-Generator帮我们自 ...

  9. cocos2d-html5学习笔记(六)--alpha2中cc.Sequence.create中的bug

    cocos2d-html5学习笔记(六)--alpha2中cc.Sequence.create中的bug http://blog.csdn.net/allenice1/article/details/ ...

  10. JVM 参数详解

    1.使用$JAVA_HOME/bin/java  可看到所有参数说明 用法: java [-options] class [args...] (执行类) 或 java [-options] -jar ...