Ubuntu 的 https协议 和 反向代理
下面假设你的域名是 git.ngapp.net , 配置服务器用 Ubuntu + Apache
ssl免费证书申请:
- 沃通提供的免费ssl证书: https://buy.wosign.com/free/
- 解压复制apache需要的文件到 /etc/apache2/ssl 目录
配置Apache
增加配置 /etc/apache2/apache2.conf
ServiceName localhost
开启需要的模块
a2enmod ssl
a2enmod proxy
a2enmod proxy_http
添加配置 /etc/apache2/sites-enabled/git.ngapp.net.conf
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/git.ngapp.net.crt
SSLCertificateKeyFile /etc/apache2/ssl/git.ngapp.net.key
SSLCertificateChainFile /etc/apache2/ssl/root_bundle.crt
ServerName git.ngapp.net
ServerAdmin zhaishuaigan@qq.com
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
AddDefaultCharset off
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
<VirtualHost *:80>
ServerName git.ngapp.net
ServerAdmin zhaishuaigan@qq.com
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</VirtualHost>
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续努力!