代码之家  ›  专栏  ›  技术社区  ›  Kareem

带有letsencrypt和apache2的KeystoneJS上的SSL

  •  0
  • Kareem  · 技术社区  · 7 年前

    我正在Ubuntu16上部署keystonejs应用程序,带有docker compose,并且有一个有效的letsencrypt证书。

    我在keystone.js中添加了以下设置

    'ssl': true
    'port': 3000,
        'admin path': 'admin',
        'ssl cert': '/etc/letsencrypt/live/mydomain.com/fullchain.pem',
        'ssl key': '/etc/letsencrypt/live/mydomain.com/privkey.pem',
        'letsencrypt': (process.env.NODE_ENV === 'production') && {
            email: 'user@gmail.com',
            domains: ['www.mydomain.com', 'mydomain.com'],
            register: true,
            tos: true,
        },
    

    服务器启动正常显示:

    app |
    app | ------------------------------------------------
    app | KeystoneJS v4.0.0 started:
    app | mydomain is ready on http://0.0.0.0:3000
    app | SSL Server is ready on https://0.0.0.0:3001
    app | ------------------------------------------------
    app |
    

    但当我访问我的网站。它不会显示为从浏览器中的url选项卡进行保护。它显示了一个小小的感叹号(!)说明:您与此网站的连接不安全。

    我的服务器上有apache2。

    在/etc/apache2/sites available/mydomain.com.conf下有:

    <VirtualHost *:80>
      # Admin email, Server Name (domain name), and any aliases
      ServerAdmin info@mydomain.com
      ServerName  mydomain.com
      ServerAlias www.mydomain.com
    
      # Index file and Document Root (where the public files are located)
      DirectoryIndex index.html
      DocumentRoot /var/www/html/mydomain.com/
      # Log file locations
      LogLevel warn
      ErrorLog  /var/www/html/mydomain.com/log/error.log
      CustomLog /var/www/html/mydomain.com/log/access.log combined
    
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyPreserveHost On
    
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
    RewriteCond %{SERVER_NAME} =mydomain.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>
    

    在/etc/apache2/sites available/mydomain.com.le.ssl.conf下

    <IfModule mod_ssl.c>
    <VirtualHost *:443>
      # Admin email, Server Name (domain name), and any aliases
      ServerAdmin info@mydomain.com
      ServerName  mydomain.com
      ServerAlias www.mydomain.com
    
      # Index file and Document Root (where the public files are located)
      DirectoryIndex index.html
      DocumentRoot /var/www/html/mydomain.com/
      # Log file locations
      LogLevel warn
      ErrorLog  /var/www/html/mydomain.com/log/error.log
      CustomLog /var/www/html/mydomain.com/log/access.log combined
    
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyPreserveHost On
    
    Include /etc/letsencrypt/options-ssl-apache.conf
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/mydomain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
    </VirtualHost>
    </IfModule>
    

    我已尝试将proxypass&proxypassreverse指向3001端口。但网站永远无法访问。 非常感谢您的帮助。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Artur Czyżewski    6 年前

    尝试禁用keystone中的ssl。通过Apache服务器代理流量时不需要它它将处理证书,并在本地与keystone通信,而不使用SSL然后你就可以从外面堵住3000个港口。

    推荐文章