一、背景需求
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/guyan/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/guyan/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/huami.com.crt" SSLCertificateKeyFile "/etc/apache2/ssl/huami.key" ProxyRequests Off ProxyPreserveHost On ProxyPass / http://127.0.0.1:9003/ ProxyPassReverse / http://127.0.0.1:9003/ </virtualhost>