源代码构建Apache反向代理(包括SSL配置)

简介:

由rpm构建的apache是适合大多数场合的应用,它包含了大多数的模块,而我们只是用它去构建反向代理,过多大模块反而不好,影响了性能,所以我们选择了针对性的源代码编译,让apache去适应我们的平台。

下载源代码:

wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.25.tar.gz

解压

tar zxvf httpd-2.2.25.tar.gz

cd httpd-2.2.25

编译安装的前提条件

yum install -y gcc gcc-c++ apr apr-devel apr-util openssl openssl-devel

根据gcc版本,和cpu架构,进行优化编译

clip_image002

使用gcc -v查看gcc的版本

clip_image004

cat /proc/cpuinfo 查看cpu型号

clip_image005

uname –r 查看 操作系统的版本

clip_image006

编译安装

CFLAGS="-march=core2 -mtune=generic -O2 -pipe" CXXFLAGS="{CFLAGS}" ./configure --enable-layout=RedHat --enable-modules=so --enable-ssl --enable-rewrite --enable-proxy

make

make install

清除调试符号,节省内存空间

strip /usr/sbin/httpd

使用httpd –M检查添加的模块

httpd -m |grep rewrite

httpd -m |grep ssl

httpd -m |grep proxy

clip_image007

使用httpd -k start 启动apache

使用 httpd -k stop 关闭

使用 httpd -k restart 重启

echo “/usr/sbin/httpd –k start” >>/etc/rc.local 设为随机启动

配置ssl

红色字体为新添加的配置

#redirect non-ssl request to ssl requres

Redirect / https://web.contoso.com

SSLSessionCache "shmcb:logs/ssl_scache(512000)"

SSLSessionCacheTimeout 300

ProxyRequests off

listen 443 https

NameVirtualHost *:443

<VirtualHost *:443>

# Site info

ServerName webprox1.contoso.com

ServerAdmin administrator@contoso.com

SSLEngine on

SSLProxyEngine on

SSLCertificateFile /etc/httpd/conf/ssl/web.crt

SSLCertificateKeyFile /etc/httpd/conf/ssl/web.key

SSLCACertificatePath /etc/httpd/conf/ssl

SSLCACertificateFile /etc/httpd/conf/ssl/ca.pem

# Rewrite engine on

RewriteEngine On

RewriteOptions Inherit

# Log filenames

ErrorLog /etc/httpd/logs/error-inotes-redirect

CustomLog /etc/httpd/logs/access-inotes-redirect common

LogLevel warn

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

# Rule 0 : If Cookie is set and user logs out, remove the cookie

RewriteCond %{HTTP_COOKIE} ^.*iNotesServer=.*

RewriteCond %{QUERY_STRING} ^Logout

RewriteRule ^/.* - [CO=iNotesServer:domino1:.contoso.com:1]

# Rule 1 : Read domino server name from first access to the mail directory,

# save it to the cookie and redirect to the mail server

RewriteCond %{REQUEST_URI} ^/(.*)/mail

RewriteRule /(.*)/mail/(.*) http://$1.contoso.com/mail/$2 [P,CO=iNotesServer:$1:.contoso.com]

# Rule 2 : If cookie is set, use it to rewrite rules for iNotes generated URLs

# and non mail DBs for the server definde in the cookie iNotesServer

RewriteCond %{REQUEST_URI} ^/favicon.ico [OR]

RewriteCond %{REQUEST_URI} ^/domjs [OR]

RewriteCond %{REQUEST_URI} ^/domjava [OR]

RewriteCond %{REQUEST_URI} ^/domcfg.nsf [OR]

RewriteCond %{REQUEST_URI} ^/iNotes [OR]

RewriteCond %{REQUEST_URI} ^/icons [OR]

RewriteCond %{REQUEST_URI} ^/iwaredir.nsf [OR]

RewriteCond %{REQUEST_URI} ^/names.nsf [OR]

RewriteCond %{REQUEST_URI} ^/mail [OR]

RewriteCond %{REQUEST_URI} ^/archive [OR]

RewriteCond %{REQUEST_URI} ^/download [OR]

RewriteCond %{REQUEST_URI} ^/dwa(.*)

RewriteCond %{HTTP_COOKIE} ^.*iNotesServer=([^;]+)

RewriteRule /(.*) http://%1.contoso.com/$1 [P,L]

# Rule 3 : if no cookie set -> on first access on the iNotes iwaredir.nsf

RewriteCond %{REQUEST_URI} ^/favicon.ico [OR]

RewriteCond %{REQUEST_URI} ^/domcfg.nsf [OR]

RewriteCond %{REQUEST_URI} ^/iwaredir.nsf [OR]

RewriteCond %{REQUEST_URI} ^/names.nsf

RewriteRule /(.*) http://domino1.contoso.com/$1 [P,L]

# Rule 4 : everything else should be redirected to the original link

RewriteCond %{REQUEST_URI} ^/

RewriteRule / http://domino1.contoso.com/ [P]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

ProxyPassReverse /domino1/mail/ http://domino1.contoso.com/mail/

ProxyPassReverse / http://domino1.contoso.com/

</VirtualHost>

clip_image009

性能优化

取消http.conf中

Include /etc/httpd/conf/extra/httpd-mpm.conf 的注释,即删除前面的#号

修改 prefork段的值

<IfModule mpm_prefork_module>

ServerLimit 1000

StartServers 15

MinSpareServers 15

MaxSpareServers 20

MaxClients 1000

MaxRequestsPerChild 3000

</IfModule>




本文转自 高文龙 51CTO博客,原文链接:http://blog.51cto.com/gaowenlong/1281165,如需转载请自行联系原作者

相关文章
|
6月前
|
网络安全 数据库
YashanDB HA节点间SSL连接配置
本指南介绍HA内部节点链路的SSL连接配置,包括客户端监听与HA节点自身监听两种方式。需使用OpenSSL工具生成证书,具体步骤参考数据库服务端SSL连接配置文档。此外,还需在数据库中开启HA的SSL连接开关并设置证书路径(仅支持绝对路径,长度≤254字节),最后重启数据库以完成配置。确保服务器已安装所需工具,详细操作请查阅相关文档。
YashanDB HA节点间SSL连接配置
|
3月前
|
网络安全 Windows
Windows IIS 10如何配置自签名SSL并实现自动跳转
本文记录了IIS配置自签名证书及HTTPS跳转的注意事项。包括解决443端口占用问题、URL Rewrite插件安装与配置、web.config修改方法,以及避免因旧教程导致的配置错误。
Windows IIS 10如何配置自签名SSL并实现自动跳转
|
6月前
|
安全 网络安全 数据库
YashanDB分布式节点间SSL连接配置
本文介绍YashanDB分布式节点间SSL连接配置方法,确保通信安全。需统一为整个集群配置SSL,使用相同根证书签名的服务器证书,否则可能导致连接失败或数据库无法启动。文章详细说明了使用OpenSSL生成根证书、服务器私钥、证书及DH文件的步骤,并指导如何将证书分发至各节点。最后,通过配置数据库参数(如`din_ssl_enable`)并重启集群完成设置。注意,证书过期需重新生成以保障安全性。
|
6月前
|
安全 Linux 网络安全
YashanDB数据库服务端SSL连接配置
YashanDB支持通过SSL连接确保数据传输安全,需在服务端生成根证书、服务器证书及DH文件,并将根证书提供给客户端以完成身份验证。服务端配置包括使用OpenSSL工具生成证书、设置SSL参数并重启数据库;客户端则需下载根证书并正确配置环境变量与`yasc_env.ini`文件。注意:启用SSL后,所有客户端必须持有根证书才能连接,且SSL与密码认证独立运行。
|
4月前
|
安全 应用服务中间件 网络安全
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
262 0
Nginx SSL/TLS协议栈中配置深度解析与实践指南-优雅草卓伊凡
|
6月前
|
存储 人工智能 数据处理
Apache Doris 2025 Roadmap:构建 GenAI 时代实时高效统一的数据底座
秉承“以场景驱动创新” 的核心理念,持续深耕三大核心场景的关键能力,并对大模型 GenAI 场景的融合应用进行重点投入,为智能时代构建实时、高效、统一的数据底座。
313 10
Apache Doris 2025 Roadmap:构建 GenAI 时代实时高效统一的数据底座
|
6月前
|
存储 Oracle 关系型数据库
MySQL 8.4 配置SSL组复制(八个步骤)
MySQL 8.4 配置SSL组复制(八个步骤)
338 0
|
27天前
|
人工智能 运维 Java
Flink Agents:基于Apache Flink的事件驱动AI智能体框架
本文基于Apache Flink PMC成员宋辛童在Community Over Code Asia 2025的演讲,深入解析Flink Agents项目的技术背景、架构设计与应用场景。该项目聚焦事件驱动型AI智能体,结合Flink的实时处理能力,推动AI在工业场景中的工程化落地,涵盖智能运维、直播分析等典型应用,展现其在AI发展第四层次——智能体AI中的重要意义。
333 27
Flink Agents:基于Apache Flink的事件驱动AI智能体框架
|
10月前
|
存储 人工智能 大数据
The Past, Present and Future of Apache Flink
本文整理自阿里云开源大数据负责人王峰(莫问)在 Flink Forward Asia 2024 上海站主论坛开场的分享,今年正值 Flink 开源项目诞生的第 10 周年,借此时机,王峰回顾了 Flink 在过去 10 年的发展历程以及 Flink社区当前最新的技术成果,最后展望下一个十年 Flink 路向何方。
691 33
The Past, Present and Future of Apache Flink

热门文章

最新文章

推荐镜像

更多