CentOS 6.2 编译Apache使其支持HTTPS

简介:
HTTPS(全 称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容 就需要SSL。 它是一个URI scheme(抽象标识符体系),句法类同http:体系。用于安全的HTTP数据传输。https:URL表明它使用了HTTP,但HTTPS存在不同 于HTTP的默认端口及一个加密/身份验证层(在HTTP与TCP之间)。这个系统的最初研发由网景公司进行,提供了身份验证与加密通讯方法,现在它被广 泛用于万维网上安全敏感的通讯,例如交易支付方面。

简介

它是由Netscape开发并内置于其浏览器 中,用于对数据进行压缩和解压操作,并返回网络上传送回的结果。HTTPS实际上应用了 Netscape的安全套接字层(SSL)作为HTTP应用层的子层。(HTTPS使用端口443,而不是像HTTP那样使用端口80来和TCP/IP进 行通信。)SSL使用40 位关键字作为RC4流加密算法,这对于商业信息的加密是合适的。HTTPS和SSL支持使用X.509数字认证,如果需要的话用户可以确认发送者是谁。
也就是说它的主要作用可以分为两种:一种是建立一个信息安全通道,来保证数据传输的安全;另一种就是确认网站的真实性。
Centos 6.2下配置https服务器的步骤,需要的朋友可以参考下。
HTTPS和HTTP的区别
一、https协议需要到ca申请证书,一般免费证书很少,需要交费。
二、http是超文本传输协议,信息是明文传输,https 则是具有安全性的ssl加密传输协议。
三、http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443。
四、http的连接很简单,是无状态的;HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,比http协议安全。

HTTPS解决的问题

一、信任主机的问题.

采 用https的服务器必须从CA (Certificate Authority)申请一个用于证明服务器用途类型的证书。该证书只有用于对应的服务器的时候,客户端才信任此主机。所以目前所有的银行系统网站,关键 部分应用都是https 的。客户通过信任该证书,从而信任了该主机。其实这样做效率很低,但是银行更侧重安全。这一点对我们没有任何异议,我们的服务器,采用的证书不管是自己发 布的还是从公众的地方发布的,其客户端都是自己人,所以我们也就肯定信任该服务器。
 
二、通讯过程中的数据的泄密和被篡改
1. 一般意义上的https,就是服务器有一个证书。
a) 主要目的是保证服务器就是他声称的服务器,这个跟第一点一样。
b) 服务端和客户端之间的所有通讯,都是加密的。
i. 具体讲,是客户端产生一个对称的密钥,通过服务器的证书来交换密钥,即一般意义上的握手过程。
ii. 接下来所有的信息往来就都是加密的。第三方即使截获,也没有任何意义,因为他没有密钥,当然篡改也就没有什么意义了。
2. 少许对客户端有要求的情况下,会要求客户端也必须有一个证书。
a) 这里客户端证书,其实就类似表示个人信息的时候,除了用户名/密码,还有一个CA 认证过的身份。因为个人证书一般来说是别人无法模拟的,所有这样能够更深的确认自己的身份。
b) 目前少数个人银行的专业版是这种做法,具体证书可能是拿U盘(即U盾)作为一个备份的载体
如果关注俺比较多,你肯定会比较眼熟,这上面的介绍来自RPM版安装。同样你可以借鉴( CentOS 6.2下配置https并实现SSL虚拟主机
注:这里使用的编译参数是用于LDAP的架构服务,如果你单纯的只需要SSL服务,或者web架构的话,一定要删减相应参数
安装Openssl
[root@chenyi ldmp]# tar zxf openssl-1.0.0e.tar.gz 
[root@chenyi ldmp]# cd openssl-1.0.0e
[root@chenyi openssl-1.0.0e]# ./config --prefix=/software/ssl --openssldir=/software/openssl shared
[root@chenyi openssl-1.0.0e]# make && make test &&make install
安装apr
[root@chenyi ldmp]# tar zxf apr-1.4.5.tar.gz 
[root@chenyi ldmp]# cd apr-1.4.5
[root@chenyi apr-1.4.5]# ./configure --prefix=/software/apr
[root@chenyi apr-1.4.5]# make && make install
安装apr-util
[root@chenyi apr-util-1.3.12]# tar zxf apr-util-1.3.12.tar.gz
[root@chenyi apr-util-1.3.12]# cd apr-util-1.3.12
[root@chenyi apr-util-1.3.12]#  ./configure --prefix=/software/apr-util --with-apr=/software/apr/ --with-ldap-include=/software/openldap/include/ --with-ldap-lib=/software/openldap/lib/ --with-berkeley-db=/software/BerkeleyDB.5.2/ [root@chenyi apr-util-1.3.12]# make && make install
安装apache
[root@chenyi httpd-2.2.21]# tar zxf httpd-2.2.21.tar.gz
[root@chenyi httpd-2.2.21]# cd httpd-2.2.21
[root@chenyi httpd-2.2.21]# ./configure --prefix=/software/apache2 --sysconfdir=/etc/httpd --enable-ssl --with-ssl=/software/openssl/ --with-z=/software/zlib/ --enable-rewrite=shared --enable-static-support --enable-deflate=shared --enable-so --enable-dav --enable-dav-fs --enable-ldap --enable-authnz-ldap --with-included-apr --with-ldap --with-ldap-include=/software/openldap/include/ --with-ldap-lib=/software/openldap/lib --with-apr=/software/apr/bin/apr-1-config --with-apr-util=/software/apr-util/bin/apu-1-config
[root@chenyi httpd-2.2.21]# make && make install
配置支持SSL
[root@chenyi httpd-2.2.21]# cd /etc/httpd/
[root@chenyi httpd]# mkdir ssl ssl.key ssl.crt
[root@chenyi httpd]# openssl req -new -out server.csr
[root@chenyi httpd]# openssl genrsa -out www.itchenyi.com.key 1024
Generating RSA private key, 1024 bit long modulus
........++++++
............................++++++
e is 65537 (0x10001)
 
[root@chenyi httpd]# openssl req -new -key www.itchenyi.com.key -out www.itchenyi.com.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:shanghai
Locality Name (eg, city) [Default City]:pudong
Organization Name (eg, company) [Default Company Ltd]:chenyi
Organizational Unit Name (eg, section) []:www
Common Name (eg, your name or your server's hostname) []:www.itchenyi.com
Email Address []:itchenyi@gmail.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@chenyi httpd]# openssl x509 -req -days 365 -in www.itchenyi.com.csr -signkey www.itchenyi.com.key -out www.itchenyi.com.crt
Signature ok
subject=/C=CN/ST=shanghai/L=pudong/O=chenyi/OU=ww/CN=www.itchenyi.com/emailAddress=itchenyi@gmail.com
Getting Private key
查看相关配置(这里也是需要你修改的地方)
[root@chenyi extra]# cat httpd-ssl.conf  | grep SSLCertificateFile
#   Point SSLCertificateFile at a PEM encoded certificate.  If
SSLCertificateFile "/etc/httpd/www.itchenyi.com.crt"
#SSLCertificateFile "/etc/httpd/server-dsa.crt"
#   the referenced file can be the same as SSLCertificateFile
[root@chenyi extra]# cat httpd-ssl.conf  | grep SSLCertificateFile
#   Point SSLCertificateFile at a PEM encoded certificate.  If
SSLCertificateFile "/etc/httpd/www.itchenyi.com.crt"
#SSLCertificateFile "/etc/httpd/server-dsa.crt"
#   the referenced file can be the same as SSLCertificateFile
修改http-ssl.conf  注:[Directory如果设置不当,那么是不能访问的]
DocumentRoot "/home/wwwroot "
<Directory /home/wwwroot>
        Order deny,allow
        Allow from all
</Directory>
ServerName www.itchenyi.com:443
ServerAdmin itchenyi@gmail.com
ErrorLog "/software/apache2/logs/error_log"
TransferLog "/software/apache2/logs/access_log"
修改/etc/httpd/httpd.conf 取消注释 大约408行
Include /etc/httpd/extra/httpd-ssl.conf
重启http服务 通过netstat查看如下:
[root@chenyi extra]# netstat -pant | grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      6124/httpd          
tcp        0      0 :::443                      :::*                        LISTEN      6124/httpd
到此通过https:www.itchenyi.com 即可访问









本文转自 lgpqdwjh 51CTO博客,原文链接:http://blog.51cto.com/itchenyi/1189006,如需转载请自行联系原作者
目录
相关文章
|
9天前
|
应用服务中间件 Linux 网络安全
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
CentOS 7.4源码编译nginx1.12 并且隐藏nginx的版本
14 0
|
4月前
|
Linux 网络安全 Apache
Centos下操作Apache httpd
Centos下操作Apache httpd
69 0
|
1月前
|
Java Linux
Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
【2月更文挑战第16天】Flume【环境搭建 01】CentOS Linux release 7.5 安装配置 apache-flume-1.9.0 并验证
29 0
|
3月前
|
关系型数据库 MySQL Linux
centos7 编译报错 cannot find -lmysqlclient
centos7 编译报错 cannot find -lmysqlclient
|
2月前
|
关系型数据库 MySQL Linux
Azkaban【部署 02】CentOS release 7.5安装配置azkaban-3.70.0安装阶段(含已编译的10个安装文件:可直接进行安装)
【2月更文挑战第5天】CentOS release 7.5安装配置azkaban-3.70.0安装阶段(含已编译的10个安装文件:可直接进行安装)
48 7
|
2月前
|
NoSQL Linux Redis
基于centos7.7编译Redis6.0
基于centos7.7 源码编译redis-6.0.6记录
56 2
|
2月前
|
Java Linux 开发工具
Azkaban【部署 01】Linux环境 CentOS Linux release 7.5.1804安装配置azkaban-3.70.0编译阶段(附安装包及gradle-4.6资源)
【2月更文挑战第4天】Linux环境 CentOS Linux release 7.5.1804安装配置azkaban-3.70.0编译阶段(附安装包及gradle-4.6资源)
29 1
|
2月前
|
前端开发 应用服务中间件 网络安全
在Apache上http强制跳转到https无效的解决办法
在Apache上http强制跳转到https无效的解决办法
|
2月前
|
Java
apache-incubator-streampark源码编译本地运行(七)
apache-incubator-streampark源码编译本地运行(七)
37 1
|
3月前
|
Linux
Linux/CentOS设置全局代理(http)
Linux/CentOS设置全局代理(http)
212 0

热门文章

最新文章