Apache2 实现https访问http服务

一、背景需求

1、开发同事 nodejs 开发项目,node  index.js 开启9003服务端口的监听服务,现在需要外部通过https 访问该服务

 

2、搭建apache2服务

1)80端口http访问,配置/etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>  
    ProxyPreserveHost On  
    ServerAdmin admin@qq.com  
    ServerName  deploy-cn.domains.com  
    DocumentRoot /home/www/watchfaces 
    DirectoryIndex homepage.htm index.html login.htm  
    ProxyPass / http://127.0.0.1:9003/  
    ProxyPassReverse / http://127.0.0.1:9003/  
</VirtualHost>  
<Directory "/home/www/watchfaces">    
    Options Indexes FollowSymLinks  
    AllowOverride None     
    Order allow,deny  
    Allow from all  
</Directory> 

2) 443端口https 访问,需要配置1)80端口http访问,配置/etc/apache2/sites-enabled/001-ssl.conf

<virtualhost *:443>
ServerName deploy-cn.huami.com
<proxy>
Order deny,allow
Allow from all
</proxy>
SSLEngine On
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLCertificateFile "/etc/apache2/ssl/domain.com.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/domain.key"
SSLCertificateChainFile "/etc/apache2/ssl/domain.com_bundle-g2-g1.crt"
ProxyRequests Off ProxyPreserveHost On ProxyPass / http://127.0.0.1:9003/ ProxyPassReverse / http://127.0.0.1:9003/ </virtualhost>

 遇到问题备注:

 如果不配置证书链,小程序里面连接服务下载文件会报错:downloadFile:fail Error: unable to verify the first certificate"

 

其它:

1、SSL服务器证书安装检查器
   https://www.myssl.cn/tools/check-server-cert.html

 

转载于:https://www.cnblogs.com/husbandmen/p/8379325.html

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值