Mac下配置Apache Httpd的Https/SSL


httpd版本: httpd-2.4.17

jdk版本: jdk1.8.0_65

参考来源:

Mac下安装Apache Httpd

Mac OS X中Apache开启ssl - 再问天

安装与配置

首先

参照博文配置好单个Httpd实例作为https的目标测试服务环境。"./servers/cluster/httpd/node-a"

Mac下安装Apache Httpd

配置证书

1. 生成主机密钥

先为ssl的key和certificate创建存放目录

:cluster Richard$ cd httpd/
:httpd Richard$ ls
httpd-2.4.17 node-a node-b
:httpd Richard$ mkdir keys
:httpd Richard$ ls
httpd-2.4.17 keys node-a node-b
:httpd Richard$ cd keys

在目标目录下执行

:keys Richard$ sudo openssl genrsa -des3 -out server.key 1024

结果

Generating RSA private key, 1024 bit long modulus
........++++++
................................++++++
e is 65537 (0x10001)
Enter pass phrase for app.key:
Verifying - Enter pass phrase for app.key:

2. 生成签署申请

* 注意以下提示输入服务器域名的时候不能用IP地址
$ openssl req -new -key app.key -out app.csr

根据提示输入参数

enerating RSA private key, 1024 bit long modulus
....................++++++
.............++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
:keys Richard$ openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
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) [AU]:CN
State or Province Name (full name) [Some-State]:Shanghai
Locality Name (eg, city) []:Shanghai
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hoau.com
Organizational Unit Name (eg, section) []:sso
Common Name (e.g. server FQDN or YOUR name) []:proxy.sso.hoau.com
Email Address []:admin@sso.hoau.com Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:Hoau123
An optional company name []:hoau.com
* 关于以上问题参数的说明
  • 首先输入客户端所用密钥(Hoau123):

      Enter pass phrase for server.key:
  • 单点登陆服务器的域名:

      Common Name (e.g. server FQDN or YOUR name)
    []:httpd-proxy1.sso.hoau.com
  • 公司的名称:

      Organization Name (eg, company)
    [Internet Widgits Pty Ltd]:hoau.comom
  • 单点登陆服务名称:

      Organizational Unit Name (eg, section)
    []: sso
  • 所在地及国别:

      State or Province Name (full name)
    [Some-State]: Shanghai
    Locality Name (eg, city)
    []: Shanghai
    Country Name (2 letter code)
    [AU]: CN

3. 生成服务器的私钥

$ openssl rsa -in app.key -out server.key

4. 生成给网站服务器签署的证书

$ sudo openssl req -new -x509 -days 3650 -key server.key -out server.crt

至此,一共生成了4个文件

配置服务器

1. httpd.conf配置

#### Richard SSL enable cache
LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cache_socache_module modules/mod_cache_socache.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

2. httpd-ssl.conf配置

  • 端口

      Listen 441 https
  • VirtualHost端口

      <VirtualHost _default_:441>
    
      #   General setup for the virtual host
    DocumentRoot "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/htdocs"
    ServerName www.example.com:441
    ServerAdmin you@example.com
    ErrorLog "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/logs/error_log"
    TransferLog "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/logs/access_log"
  • SSLCertificateKeyFile路径

      SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/keys/server.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server-dsa.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server-ecc.crt"
  • SSLCertificateFile路径

      SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/keys/server.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server-dsa.crt"
    #SSLCertificateFile "/Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/server-ecc.crt"
* 注意:如果出现错误ssl_error_rx_record_too_long,可能是因为端口没有配置对,需要检查上面默认Listen和VirtualHost里面的端口设置

运行

执行命令

httpd Richard$ sudo ./node-a/bin/httpd -f /Users/Richard/Documents/Dev/servers/cluster/httpd/node-a/conf/httpd.conf -k start

如果提示错误

SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).

则需要检查httpd.conf里面和Cache相关的配置

测试

用浏览器访问https://proxy.sso.hoau.com:441,会出现结果

结束

Mac下配置Apache Httpd的Https/SSL的更多相关文章

  1. 【高可用HA】Apache (4) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk

    Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_jk httpd版本: httpd-2.4.17 jk版本: tomcat-connectors-1.2.41 参考 ...

  2. 【高可用HA】Apache (3) —— Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy

    Mac下配置Apache Httpd负载均衡(Load Balancer)之mod_proxy httpd版本: httpd-2.4.17 参考来源: Apache (1) -- Mac下安装Apac ...

  3. 【高可用HA】Apache (1) —— Mac下安装Apache Httpd到自定义路径(非/etc/apache2)

    Mac下安装Apache Httpd httpd版本: httpd-2.4.17 参考来源: Tomcat Clustering - A Step By Step Guide Apache HTTP ...

  4. Mac下配置Apache,PHP

    注:如果觉得终端下编辑太麻烦,也可以直接将文件拖出来手动编辑后在放回原文件夹替换即可 1.启用Apache: 在Mac下打开终端,输入“sudo apachectl start”(不包含引号,下同) ...

  5. Mac下配置Apache服务

    这篇文章主要是针对Mac用户,第一次搭建本地开发环境的同学,已经搭建过的同学可以忽略. Mac自带的Apache还是XAMPP? That is a question. 其实自带的apache也够用了 ...

  6. Mac下配置apache

    一.前言 今天遇到问题,怎么配置apache在Mac上,原来Mac自带apache,只需要自己开启配置一下就行了. 二.步骤: 1.修改apache的http_conf文件 打开finder前往/pr ...

  7. mac下配置Apache虚拟域名方案,以及遇到的坑(转)

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

  8. mac下配置Apache虚拟域名方案,以及遇到的坑

      1. 配置Apache虚拟域名 1.执行    sudo vi /etc/apache2/httpd.conf 开始配置httpd.conf 的文件; //配置listen 80端口(默认配置), ...

  9. Mac下配置Apache服务器

    有的时候,我们需要在内网工作组中分享一些文件或是后台接口没有及时给出,你又想要模拟真实数据,直接在项目里创建plist也可以做到这种需求,但难免让工程变得冗余且看起来比较Low.这个时候就看出配置本地 ...

随机推荐

  1. CListCtrl自适应宽度

    原文链接: http://blog.csdn.net/benny5609/article/details/1967084 void CListCtrlExDlg::AdjustColumnWidth( ...

  2. sql server中QUOTENAME()函数的用法

    操作sql server尤其是写存储过程时,要用到各种各样的函数,今天就总结一个quotename()的用法. 1.语法: quotename('character_string'[,'quote_c ...

  3. javascript 中的==(相等运算符)与===(等同运算符)比较

    javascript 中的==(相等运算符)与===(等同运算符)比较:(1)==用于一般比较,===用于严格比较,(2)==在比较的时候可以转换数据类型,===严格比较,只要类型不匹配就返回flas ...

  4. Java Date and Calendar examples

    Java Date and Calendar examples This tutorial shows you how to work with java.util.Date and java.uti ...

  5. Python 爬虫 不得不说的 清洗

    今天就聊聊爬虫的清洗,下载网页只是最简单的一个步骤,最让人头疼的是数据的清洗. 为什么要这样说呢,因为爬虫首先是获得数据,清洗是把非结构化的数据转换成结果化的数据,这个时候是最考验人的时候. 如果是国 ...

  6. django官方文档--对静态文件的管理

    一.入门级理解: 在django中对静态文件的管理和模板(template)的思路是一样的.在模板的管理中django是把app用到 到的模板都保存到app目录下的templates子目录中. 静态文 ...

  7. fastdfs 图片服务器 使用java端作为客户端上传图片

    之前有说道搭建fastdfs作为图片服务器,但是没有说明如何真正在代码里调用,那么今天大致讲一下,如何使用java客户端进行上传 首先你得要有一个客户端,导入到eclipse中即可 git地址如下: ...

  8. 深入理解Linux内核-内核同步

    内核基本的同步机制: 抢占内核的主要特点:一个在内核态运行的进程,可能在执行内核函数期间被另外一个进程取代. 内核抢占:Linux 2.6允许用户在编译内核的时候配置十分启用 进程临界区:每个进程中访 ...

  9. android studio - No compatible file types found

    今天在使用AS新建一个C++类时候,输完了类名,对话框却显示下面的提示,一直不知道为什么 [解决方案] 在app目录下的build.gradle文件中添加下列代码: externalNativeBui ...

  10. Content-Type中application/x-www-form-urlencoded 和 multipart/form-data的区别

    1.什么是Content-Type Form的enctype属性表示页面表单数据向服务端传输时的编码方式, 常用有两种:application/x-www-form-urlencoded和multip ...