取消ssl及proxy相关注释
#LoadModule ssl_module modules/mod_ssl.so (去掉前面的#号)
#Include conf/extra/httpd-ssl.conf (去掉前面的#号)
#LoadModule proxy_module modules/mod_proxy.so (去掉前面的#号)
#LoadModule proxy_http_module modules/mod_proxy_http.so (去掉前面的#号)
cmd进入命令行,进入apache安装目录的bin目录。
执行命令:set OPENSSL_CONF=..\conf\openssl.cnf
执行命令:openssl genrsa -out server.key 1024
完成后,会在bin目录下生成server.key文件
执行命令:openssl req -new -out server.csr -key server.key
完成后,会在bin目录下生成server.csr文件,其中 Common Name[] 需要与配置文件中的ServerName一致,否则apache启动时将会报错。
执行命令:openssl genrsa -out ca.key 1024
完成后,会在目录bin下生成ca.key文件
执行命令:openssl req -new -x509 -days 365 -key ca.key -out ca.crt
完成后,会在目录bin下生成ca.crt文件,此处填写的信息与2.3步中类似。
执行命令:openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key
此处如果没有创建好相关目录,将会报如下错误:
根据提示,手动创建相关目录:在bin下新建demoCA文件夹bin/demoCA在demoCA下新建index.txtbin/demoCA/index.txt在demoCA下新建serial.txt,其内容为01,重命名删除.txt后缀bin/demoCA/serial在demoCA下新建newcert文件夹bin/demoCA/newcerts
根据需要修改httpd-ssl.conf的默认端口号"443",这里将所有的443修改为"6443",同时修改ServerName。
具体如下:Listen 6443 ServerName localhost提示:此处如果保持https默认的443端口,则访问的时候,无需再加端口号。
在apache安装目录的conf目录下,新建一个key目录,名称随意,然后将bin目录中的相关证书复制到key目录中。key目录最终的文件结构如下:
接着修改conf/extra/httpd-ssl.conf文件中的如下内容:SSLCertificateFile "xxx/conf/key/server.crt"SSLCertificateKeyFile "xxx/conf/key/server.key"SSLCACertificateFile "xxx/conf/key/ca.crt"#SSLVerifyClient require (去掉前面的#号,进行客户端验证时需要)#SSLVerifyDepth 1 (去掉前面的#号,把10改为1,进行客户端验证时需要)
在浏览器中,输入https://localhost:6443,如果页面出现提示 It works! ,则说明https配置成功了。如图:
ServerName localhost
DocumentRoot D:/javapro/bms
SSLEngine on
SSLProxyEngine on
SSLCertificateFile "D:/myplatform/Apache2.2/conf/key/server.crt"
SSLCertificateKeyFile "D:/myplatform/Apache2.2/conf/key/server.key"
Options None
AllowOverride All
Order allow,deny
Allow From All
ServerName local.bms
DocumentRoot "D:/javapro/bms"
Alias /bms "D:/javapro/bms"
Options None
AllowOverride All
Order allow,deny
Allow From All
ServerName localhost
SSLEngine on
SSLProxyEngine on
SSLCertificateFile "D:/myplatform/Apache2.2/conf/key/server.crt"
SSLCertificateKeyFile "D:/myplatform/Apache2.2/conf/key/server.key"
ProxyRequests Off
Order allow,deny
Allow from all
ProxyPass /bms http://local.bms/bms
ProxyPassReverse /bms http://local.bms/bms
ServerName local.bms
DocumentRoot "D:/javapro/bms"
Options None
AllowOverride All
Order allow,deny
Allow From All
ServerName localhost
SSLEngine on
SSLProxyEngine on
SSLCertificateFile "D:/myplatform/Apache2.2/conf/key/server.crt"
SSLCertificateKeyFile "D:/myplatform/Apache2.2/conf/key/server.key"
ProxyRequests Off
Order allow,deny
Allow from all
ProxyPass / http://local.bms/
ProxyPassReverse / http://local.bms/