Ubuntu 的 https协议 和 反向代理

下面假设你的域名是 git.ngapp.net , 配置服务器用 Ubuntu + Apache

ssl免费证书申请:

  1. 沃通提供的免费ssl证书: https://buy.wosign.com/free/
  2. 解压复制apache需要的文件到 /etc/apache2/ssl 目录

配置Apache

增加配置 /etc/apache2/apache2.conf
  1. ServiceName localhost
开启需要的模块
  1. a2enmod ssl
  2. a2enmod proxy
  3. a2enmod proxy_http
添加配置 /etc/apache2/sites-enabled/git.ngapp.net.conf
  1. <VirtualHost *:443>
  2. SSLEngine On
  3. SSLCertificateFile /etc/apache2/ssl/git.ngapp.net.crt
  4. SSLCertificateKeyFile /etc/apache2/ssl/git.ngapp.net.key
  5. SSLCertificateChainFile /etc/apache2/ssl/root_bundle.crt
  6. ServerName git.ngapp.net
  7. ServerAdmin zhaishuaigan@qq.com
  8. ProxyPreserveHost On
  9. ProxyRequests Off
  10. <Proxy *>
  11. AddDefaultCharset off
  12. Order deny,allow
  13. Allow from all
  14. </Proxy>
  15. ProxyPass / http://localhost:3000/
  16. ProxyPassReverse / http://localhost:3000/
  17. </VirtualHost>
  18. <VirtualHost *:80>
  19. ServerName git.ngapp.net
  20. ServerAdmin zhaishuaigan@qq.com
  21. RewriteEngine on
  22. RewriteCond %{SERVER_PORT} !^443$
  23. RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  24. </VirtualHost>
文章不错, 赏你二两银子

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续努力!