需求场景:通过访问apache的http地址,反向代理访问后端的https服务,而且路径带有只能特定模块才反向代理

配置如下

 listen 

 <VirtualHost *:>
#管理员邮箱 随便填 可不要此指令
ServerAdmin webmaster@dummy-host.example.com
#域名 为IP地址
ServerName 本机ip <Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLProxyEngine On #https代理最关键就是这个
ProxyPreserveHost On
ProxyRequests Off #关闭正向代理
#ProxyPassMatch ^/foo/bar https://123.123.123.2 #443端口这么写
ProxyPassMatch ^/foo/bar https://123.123.123.2:6079(如果是443端口不要加了,否则连接不上,可以打开httpd.conf 打开debug级别日志能看到)
ProxyPass / ! #表示不是上面匹配的路径不转发,走默认的httpd.conf DocumentRoot
ProxyPassReverse / ! #表示不是上面匹配的路径不转发,走默认的httpd.conf DocumentRoot
ErrorLog /var/log/httpd/test_error_log
CustomLog /var/log/httpd/test_access_log combined
</VirtualHost

效果展示

curl http://本地ip:8182/foo/bar/123

会转发到后端

示范日志,需要httpd开启debug 在httpd.conf 修日志级别重启l即可

[Thu Sep  ::27.575036 ] [authz_core:debug] [pid ] mod_authz_core.c(): [client 192.168.10.30:] AH01628: authorization result: granted (no directives)
[Thu Sep ::27.575188 ] [proxy:debug] [pid ] mod_proxy.c(): [client 192.168.10.30:] AH01143: Running scheme https handler (attempt )
[Thu Sep ::27.575197 ] [proxy_ajp:debug] [pid ] mod_proxy_ajp.c(): [client 192.168.10.30:] AH00894: declining URL https://123.123.123.2/foo/bar/getFPInfoByNSRSBH
[Thu Sep ::27.575203 ] [proxy_fcgi:debug] [pid ] mod_proxy_fcgi.c(): [client 192.168.10.30:] AH01076: url: https://123.123.123.2/foo/bar/getFPInfoByNSRSBH proxyname: (null) proxyport: 0
[Thu Sep ::27.575207 ] [proxy_fcgi:debug] [pid ] mod_proxy_fcgi.c(): [client 192.168.10.30:] AH01077: declining URL https://123.123.123.2/foo/bar/getFPInfoByNSRSBH
[Thu Sep ::27.575221 ] [proxy:debug] [pid ] proxy_util.c(): AH00942: HTTPS: has acquired connection for (123.123.123.2)
[Thu Sep ::27.575229 ] [proxy:debug] [pid ] proxy_util.c(): [client 192.168.10.30:] AH00944: connecting https://123.123.123.2/foo/bar/getFPInfoByNSRSBH to 123.123.123.2:443
[Thu Sep ::27.575321 ] [proxy:debug] [pid ] proxy_util.c(): [client 192.168.10.30:] AH00947: connected /foo/bar/getFPInfoByNSRSBH to 123.123.123.2:
[Thu Sep ::27.581116 ] [proxy:debug] [pid ] proxy_util.c(): AH02824: HTTPS: connection established with 123.123.123.2: (123.123.123.2)
[Thu Sep ::27.581151 ] [proxy:debug] [pid ] proxy_util.c(): AH00962: HTTPS: connection complete to 123.123.123.2: (123.123.123.2)
[Thu Sep ::27.581161 ] [ssl:info] [pid ] [remote 123.123.123.2:] AH01964: Connection to child established (server 192.168.10.30:)
[Thu Sep ::27.598908 ] [ssl:debug] [pid ] ssl_engine_kernel.c(): [remote 123.123.123.2:] AH02275: Certificate Verification, depth , CRL checking mode: none [subject: CN=Encryption Everywhere DV TLS CA - G1,OU=www.digicert.com,O=DigiCert Inc,C=US / issuer: CN=DigiCert Global Root CA,OU=www.digicert.com,O=DigiCert Inc,C=US / serial: 0279AC458BC1B245ABF98053CD2C9BB1 / notbefore: Nov :: GMT / notafter: Nov :: GMT]
[Thu Sep ::27.599201 ] [ssl:debug] [pid ] ssl_engine_kernel.c(): [remote 123.123.123.2:] AH02275: Certificate Verification, depth , CRL checking mode: none [subject: CN=*.ele-cloud.com / issuer: CN=Encryption Everywhere DV TLS CA - G1,OU=www.digicert.com,O=DigiCert Inc,C=US / serial: 01B4CA2CA4522D242C3055C4C5920F94 / notbefore: Aug :: GMT / notafter: Aug :: GMT]
[Thu Sep ::27.610271 ] [ssl:debug] [pid ] ssl_engine_kernel.c(): [remote 123.123.123.2:] AH02041: Protocol: TLSv1., Cipher: ECDHE-RSA-AES128-SHA256 (/ bits)
[Thu Sep ::27.760324 ] [proxy:debug] [pid ] proxy_util.c(): AH00925: initializing worker https://123.123.123.2 shared
[Thu Sep ::27.760336 ] [proxy:debug] [pid ] proxy_util.c(): AH00927: initializing worker https://123.123.123.2 local
[Thu Sep ::27.760353 ] [proxy:debug] [pid ] proxy_util.c(): AH00931: initialized single connection worker in child for (123.123.123.2)
[Thu Sep ::28.238290 ] [proxy:debug] [pid ] proxy_util.c(): AH00943: https: has released connection for (123.123.123.2)

顺便记录反向代理http

[root@oc conf.d]# vim vhost.conf

listen 

<VirtualHost *:>

    #管理员邮箱

    ServerAdmin webmaster@dummy-host.example.com

    #域名

    ServerName 本机ip

    <Proxy *>

        Order deny,allow

        Allow from all

    </Proxy>

    ProxyPreserveHost On

    ProxyRequests Off #关闭正向代理

    ProxyPassMatch ^/recipt/checkFp http://123.48.78.9:8080 #默认端口80,不需要填端口

    ProxyPass / !

    ProxyPassReverse / !

    ErrorLog /var/log/httpd/test_error_log

    CustomLog /var/log/httpd/test_access_log combined

</VirtualHost>

反向代理不过滤path

[root@oc conf.d]# vim vhost.conf
listen <VirtualHost *:>
#管理员邮箱
ServerAdmin webmaster@dummy-host.example.com
#域名
ServerName 本机ip <Proxy *>
Order deny,allow
Allow from all
</Proxy> ProxyPreserveHost On
ProxyRequests Off #关闭正向代理 ProxyPass / http://123.48.78.9:8080
ProxyPassReverse / http://123.48.78.9:8080
ErrorLog /var/log/httpd/test_error_log
CustomLog /var/log/httpd/test_access_log combined
</VirtualHost>

apache 2.4 httpd 2.4.6 反向代理后端的服务为HTTPS https 基于centos7的更多相关文章

  1. Apache服务器中设置端口映射和反向代理的方法

    在/etc/httpd/conf路径下的httpd.conf文件###new add for webui.cong###Include "E:/local/Wamp/bin/apache/A ...

  2. tomcat部署虚拟主机-搭建两个应用以及httpd和Nginx的反向代理

    实验环境:CentOS7 前提:已经安装好tomcat,未安装请查看http://www.cnblogs.com/wzhuo/p/7111135.html: 目的:基于主机名访问两个应用: [root ...

  3. Nginx反向代理+负载均衡简单实现(https方式)

    背景:A服务器(192.168.1.8)作为nginx代理服务器B服务器(192.168.1.150)作为后端真实服务器 现在需要访问https://testwww.huanqiu.com请求时从A服 ...

  4. Nginx负载均衡反向代理 后端Nginx获取客户端真实IP

    Nginx 反向代理后,后端Nginx服务器无法正常获取客户端的真实IP nginx通过http_realip_module模块来实现的这需要重新编译,如果提前编译好了就无需重新编译了1,重新编译ng ...

  5. 十.nginx反向代理负载均衡服务实践部署

    期中集群架构-第十章-nginx反向代理负载均衡章节章节====================================================================== 0 ...

  6. haproxy反向代理环境部署(http和https代理)

    操作背景:前方有一台haproxy代理机器(115.100.120.57/192.168.1.7),后方两台realserver机器(192.168.1.150.192.168.1.151,没有公网i ...

  7. nginx设置反向代理后端jenklins,页面上的js css文件无法加载

    转载 2017年06月14日 22:36:59 8485 问题现象: nginx配置反向代理后,网页可以正常访问,但是页面上的js css文件无法加载,页面样式乱了. (1)nginx配置如下: (2 ...

  8. nginx反向代理-后端服务器组设置

    nginx服务器的反向代理时其最常用的重要功能之一,在实际工作中应用广泛,涉及的配置指令也比较多.下面会尽量详细地介绍对应的指令,及其使用状态. 反向代理一般是互联网需要向内网拉取资源,比如访问一个w ...

  9. Linux基础-----------nginx安装和nginx web、nginx反向代理、nfs 服务

    作业一:nginx服务1)二进制安装nginx包 yum install epel-release -y 先安装epel-release 再查看yum源中已经安装上了epel相关文件 中间省去了一些安 ...

随机推荐

  1. Java并发编程3-抽象同步队列AQS详解

    AQS是AtractQueuedSynchronizer(队列同步器)的简写,是用来构建锁或其他同步组件的基础框架.主要通过一个int类型的state来表示同步状态,内部有一个FIFO的同步队列来实现 ...

  2. 王艳 201771010127《面向对象程序设计(java)》第十四周学习总结

    实验十四  Swing图形界面组件 一理论部分 1.Layout Manager(布局管理器):布局管理器是一组类,实现 java.awt.LayoutManager 接口,决定容器中组件的位置和大小 ...

  3. 工业互联网可视化系统风格的抉择:线框模式之 3D 数据中心机房的实现

    前言 3D 可视化,就是把复杂抽象的数据信息,以合适的视觉元素及视角去呈现,方便系统的展示.维护和管理.而在可视化系统的搭建选择上,所呈现的风格样式效果多种多样,各自所突出的适用场合也不尽相同.对于科 ...

  4. ES[7.6.x]学习笔记(十)聚合查询

    聚合查询,它是在搜索的结果上,提供的一些聚合数据信息的方法.比如:求和.最大值.平均数等.聚合查询的类型有很多种,每一种类型都有它自己的目的和输出.在ES中,也有很多种聚合查询,下面我们看看聚合查询的 ...

  5. ngnix随笔二

    ngnix配置文件 1.rpm -ql nginx /etc/logrotate.d/nginx /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/defa ...

  6. [ES6系列-03]ES6中关于参数相关特性详解(参数默认值与参数解构赋值与剩余参数)

    [原创] 码路工人 大家好,这里是码路工人有力量,我是码路工人,你们是力量. 今天总结一下 ES6 中跟参数相关的内容. 欢迎补充斧正.留言交流. 让我们互相学习一起进步. 1. ES6 参数默认值( ...

  7. DCL单例为什么要加Volatile

    拿一个对象创建赋值来说 class T{ int elem = 1; } T t = new T(); 上段代码转换成汇编码为: 0 new #2 <T> 3 dup 4 invokesp ...

  8. Rocket - diplomacy - LazyModuleImpLike

    https://mp.weixin.qq.com/s/gDbUto1qd7uWbpnxovr5pg   介绍LazyModuleImpLike类的实现.     1. wrapper   LazyMo ...

  9. 个人记录HTML基础笔记

    无功能性标签 en strong 都表示强调,strong强调级更高 abbr 缩写 <abbr title="wangweiwang">w3c</annr> ...

  10. Spring Boot笔记(一) springboot 集成 swagger-ui

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 1.添加依赖 <!--SpringBoot整合Swagger-ui--> <depen ...