#LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件:yum -y install mod_ssl openssl)
#Include conf/extra/httpd-ssl.conf(删除行首的配置语句注释符号“#”,保存后退出) # 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile cert/a_public.crt
# 证书私钥配置
SSLCertificateKeyFile cert/a.key
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile cert/a_chain.crt
DocumentRoot "${WEBROOT}/www/"
ServerName www.test.com
ServerAdmin admin@admin.com
ErrorLog "${SRVROOT}/logs/error.log"
TransferLog "${SRVROOT}/logs/access.log"
SSLEngine on
SSLCertificateFile "${SRVROOT}/cert/a_public.crt"
SSLCertificateKeyFile "${SRVROOT}/cert/a.key"
SSLCertificateChainFile "${SRVROOT}/cert/a_chain.crt"
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]
ServerName www.test.com
SSLEngine on
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off
SSLCertificateFile "${SRVROOT}/cert/a.crt"
SSLCertificateKeyFile "${SRVROOT}/cert/a.key"
SSLCertificateChainFile "${SRVROOT}/cert/server.crt"
Order deny,allow
Allow from all
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / https://127.0.0.1:3030/
ProxyPassReverse / https://127.0.0.1:3030/
注意:
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off
这两句很重要,否则会报
Reason: Error during SSL Handshake with remote server
补充更优秀方案2
#apache设置转发
#开启扩展
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
#配置如下:
ServerAdmin tony@163.com
ServerName test.abc.com
SSLEngine on
SSLCertificateFile "${SRVROOT}/cert/abc_public.crt"
SSLCertificateKeyFile "${SRVROOT}/cert/abc.key"
SSLCertificateChainFile "${SRVROOT}/cert/abc_chain.crt"
ProxyRequests off
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://127.0.0.1:3030/$1 [P,L]
ProxyPass / http://127.0.0.1:3030/
ProxyPassReverse / http://127.0.0.1:3030/