【发布时间】:2019-04-06 19:33:35
【问题描述】:
我正在使用 docker-compose 在 Ubuntu 16 上部署 keystonejs 应用程序并拥有有效的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 端口。但是该站点将永远无法访问。 非常感谢任何帮助。
【问题讨论】:
标签: node.js express apache2 lets-encrypt keystonejs