Ubuntu 16.04 + Apache2 SSL 代理上的 Rocket.Chat 不起作用

Ubuntu 16.04 + Apache2 SSL 代理上的 Rocket.Chat 不起作用

问题:Rocket.Chat Server 通过 HTTP 完美运行,但不幸的是我无法让它与 HTTPS 和 Apache2 反向代理一起工作......

Apache-Config sub.example.com (Rocket.Chat):

> <VirtualHost IP:443>
> 
> ServerAdmin [email protected]
> ServerName sub.example.com
> ServerAlias www.sub.example.com
> ErrorLog /var/log/chat.sub.example.com_error.log
> TransferLog /var/log/chat.sub.example.com_access.log
> LogLevel info
> SSLEngine On
> SSLCertificateFile /etc/letsencrypt/live/sub.example.com/fullchain.pem
> SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.com/privkey.pem
> 
> <Location />
>         Order allow,deny
>         Allow from all
> </Location>
> 
> RewriteEngine On
> RewriteCond %{HTTP:Upgrade} =websocket [NC]
> RewriteRule /(.*) ws://localhost:3000/$1 [P,L]
> RewriteCond %{HTTP:Upgrade}           !=websocket [NC]
> RewriteRule /(.*) http://localhost:3000/$1 [P,L]
> 
> ProxyPassReverse / http://localhost:3000/
> </VirtualHost>

顶部运行 example.com,它还通过 https 提供其他内容:

<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.example.com [OR]
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]


  </VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Caddy-Files 如下所示:

> https://sub.example.com
> proxy / localhost:3000 {
>   websocket
>   transparent
> }

Caddy-Status(每次我将默认的 caddy 文件编辑为上述设置时,服务似乎都会失败):

https://cloud.githubusercontent.com/assets/26794734/24507484/def39ce6-1560-11e7-8233-265c5a833b39.png

摘要(/./ --> 链接删除):

[网站] HTTPS https://example.com --> 正在运行

[Rocket.Chat] HTTP http://./sub.example.com:3000 --> 正在运行

[Rocket.Chat] HTTPS https:/./sub.example.com:3000 --> 无法正常工作 (ERR_CONNECTION_CLOSED)

有人能给我点提示吗?我认为这是顶级域名和 VirtualHosts 的问题...非常感谢!

答案1

我在 centos7 和 apache 上遇到了同样的问题,通过安装中间证书解决了!看来移动 API 需要它。使用以下方法测试您的服务器 SSL https://www.ssllabs.com/ssltest/index.html。如果在证书测试中收到“链不完整”错误,请使用https://certificatechain.io/来解决它。

在最后一个站点上粘贴您的实际 SSL 证书,并将结果用作中间证书。重新启动 httpd,ssllabs 中的另一项测试在证书链中必须看起来正常,并且移动应用程序听起来不错。

相关内容