Apache http 服务器如何启用和设置 https 连接以提供加密的 http 通讯教程
来源:互联网 发布:hadoop git 源码下载 编辑:程序博客网 时间:2024/05/21 09:21
原文地址:http://blog.csdn.net/joyous/article/details/50834504#comments
Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源代码的网页服务器软件,可以在大多数电脑操作系统中运行,由于其跨平台和安全性。被广泛使用,是最流行的Web服务器软件之一,快速,可扩展性强,是 Apache http 服务器的特点。
Apache HTTP Server 默认开启 HTTP 也就是 80 端口,并提供 HTTP 服务,但也可以通过创建证书和简单的配置,打开 HTTPS 用于安全连接,用于加密通讯,如果仅仅是为了加密通讯,则可以自己生成证书,也可向认证机构申请,本文将介绍自己生成证书。
以下配置基于 Apache http 2.4.17 / 2.4.18 撰写。
以 FreeBSD 系统为例:
控制台进入 apache/bin 目录,运行 openssl 程序完成生成 key 的任务,需要以下几个步骤:
# Generating RSA 算法生成 2048 bit Key
openssl genrsa -out server.key 2048
# 或者 des3 算法的 2048 bit Key, 任选一种
openssl genrsa -des3 -out server.key 2048
# 做一个 server.key 的备份(可选操作)
openssl rsa -in server.key -out server.key.unsecure
# 生成 RSA 私钥,需要填写一些信息(我选择的是下面第一种方式)
# openssl req -new -key server.key -out server.csr
openssl req -config ../conf/openssl.cnf -new -key server.key -out server.csr
# 创建一个自签名的证书,需要填写一些信息
# openssl req -new -x509 -nodes -sha1 -days 3650 -key server.key -out server.crt -extensions usr_cert
openssl req -config ../conf/openssl.cnf -new -x509 -nodes -sha1 -days 3650 -key server.key -out server.crt -extensions usr_cert
至此,证书制作完成,Apache https 安全配置需要两个文件,分别是 server.crt 和 server.key,将这两个文件拷贝到apache/conf 目录。
编辑 httpd.conf 文件
# 添加 443 侦听
Listen 443
# 打开 SSL 模块
LoadModule ssl_module modules/mod_ssl.so
# 虚拟主机设置,修改端口,并补充以下几项(红色部分要写文件的绝对路径)
<VirtualHost *:443>
...
...
SSLEngine on
SSLCertificateFile conf/server.crt
SSLCertificateKeyFile conf/server.key
</VirtualHost>
重启服务器
便可以通过 https://localhost 访问主机,见到类似下图的提示,便可确认 https 安全连接设置完成,且已经成功通过浏览器打开,而浏览器和服务器之间也将通过加密数据进行通讯。
资料参考来源
https://httpd.apache.org/docs/2.4/ssl/ssl_faq.html
https://httpd.apache.org/docs/2.4/ssl/
Q群讨论 236201801
- Apache http 服务器如何启用和设置 https 连接以提供加密的 http 通讯教程
- Apache http 服务器如何启用和设置 https 连接以提供加密的 http 通讯教程
- XMLHttpRequest提供客户端同http服务器通讯的协议
- apache如何设置http自动跳转到https
- Apache HTTP 服务器的虚拟主机设置
- Apache Http 服务器安装教程
- 如何在 Apache 中启用 HTTP/2
- 如何在 Apache 中启用 HTTP/2
- 如何在Apache中方便地切换http和https?
- 阿里云服务器Apache环境下搭建HTTPS环境并且设置http自动跳转到https
- 判断是不是以http:// ftp://和https:// 开头的URL
- 服务器设置http自动转跳https
- 服务器 apache配置https,http强制跳转https
- 让apache服务器可以保证http和https同时访问(解决https可以访问而http不能访问)
- 让apache服务器可以保证http和https同时访问(解决https可以访问而http不能访问)
- apache做http和https反向代理
- 配置postfix和dovecot启用SSL以加密连接
- HTTPS 服务器和客户端如何进行加密解密的?
- NZT在线源安装教程
- 读书笔记 effective c++ Item 15 在资源管理类中提供对原生(raw)资源的访问
- 【bzoj3295】动态逆序对 CDQ分治
- Jenkins+Dokcer,run一个docker demo
- Java虚拟机:类加载器与双亲委派模型
- Apache http 服务器如何启用和设置 https 连接以提供加密的 http 通讯教程
- 50行代码实现对抗生成网络GAN
- webpack中学习到的拓扑排序
- DNA Consensus String
- 递推等价-动态规划
- 正则表达式30分钟入门
- 安装Linux14.04详细步骤
- Struts2初步学习小结
- 实现手机拍照