Apache: cURL: ssl3_get_record: apache2 ssl 版本号错误

Jas*_*Jas 6 ssl curl apache2.4

我有一台服务器,同时运行 2 个 Magento 站点。站点 1 在 SSL 下工作正常,而站点 2 每当我访问它时都会返回错误。

我尝试使用 cURL 测试该网站:

curl -v https://example2-domain.com/
Run Code Online (Sandbox Code Playgroud)

cURL 抛出此错误:

*   Trying 97.74.223.135...
* TCP_NODELAY set
* Connected to example2-domain.com (97.74.233.135) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* (304) (OUT), TLS handshake, Client hello (1):
* error:1408F10B:SSL routines:ssl3_get_record:wrong version number
* stopped the pause stream!
* Closing connection 0
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
Run Code Online (Sandbox Code Playgroud)

以下是 Apache VirtualHost 块供参考:

<VirtualHost 97.74.233.135:8080>
    ServerName www.example-domain.com
    ServerAlias example-domain.com
    DocumentRoot /home/example/public_html
    DirectoryIndex index.php
    ServerAdmin webmaster@example-domain.com
    UseCanonicalName Off
    ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/
    <Directory /home/example/public_html>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 97.74.233.135:8080>
    ServerName example-domain2.com
    DocumentRoot /home/example2/public_html
    DirectoryIndex index.php
    ServerAdmin webmaster@example-domain2.com
    UseCanonicalName Off
    ScriptAlias /cgi-bin/ /home/example2/public_html/cgi-bin/
    <Directory /home/example2/public_html>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 97.74.233.135:443>
    ServerAdmin webmaster@example-domain.com
    ServerName www.example-domain.com
    LogLevel warn
    ErrorLog /var/log/apache2/example-domain.com-ssl-error.log
    CustomLog /var/log/apache2/example-domain.com-ssl-access.log combined
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:6081/
    ProxyPassReverse / http://127.0.0.1:6081/
    RequestHeader set X-Forwarded-Port "443"
    RequestHeader set X-Forwarded-Proto "https"
    SSLEngine On
    SSLCertificateFile /ssl/example-domain.crt
    SSLCertificateKeyFile /ssl/example-domain-key.txt
    SSLCertificateChainFile /ssl/example-domain.ca-bundle
</VirtualHost>

<VirtualHost 97.74.233.135:443>
    ServerAdmin webmaster@example-domain2.com
    ServerName example-domain2.com
    LogLevel warn
    ErrorLog /var/log/apache2/example-domain2.com-ssl-error.log
    CustomLog /var/log/apache2/example-domain2.com-ssl-access.log combined
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:6081/
    ProxyPassReverse / http://127.0.0.1:6081/
    RequestHeader set X-Forwarded-Port "443"
    RequestHeader set X-Forwarded-Proto "https"
    SSLEngine On
    SSLCertificateFile /ssl/example-domain2.com.crt
    SSLCertificateKeyFile /ssl/example-domain2-key.txt
    SSLCertificateChainFile /ssl/example-domain2.ca-bundle
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

如果您想知道端口 6081 上有什么,Varnish 配置为位于该端口上。

有人可以告诉我为什么会发生这种情况吗?谢谢!

Pro*_*ton 5

当我在Ubuntu 20.04上的Apache2 Web 服务器上为网站设置 SSL 时,也遇到了同样的问题。

每次我运行一个curl请求时:

curl https://corebanking.test.vggdev.com
Run Code Online (Sandbox Code Playgroud)

或者

curl https://my-website.com:443
Run Code Online (Sandbox Code Playgroud)

我收到错误:

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number
Run Code Online (Sandbox Code Playgroud)

我检查了网站的配置文件 ( my-website.conf),看起来不错。

这是我修复它的方法

我发现目录中没有该网站(my-website.conf)的配置文件/etc/apache2/sites-enabled。所以配置没有启用。

我所要做的就是将符号链接my-website.conf/etc/apache2/sites-enabled以下目录:

sudo ln -s /etc/apache2/sites-available/my-website.conf /etc/apache2/sites-enabled/my-website
Run Code Online (Sandbox Code Playgroud)

接下来,我列出了该目录的内容,/etc/apache2/sites-enabled以确保网站的配置文件 ( my-website.conf) 在那里:

ls /etc/apache2/sites-enabled/
Run Code Online (Sandbox Code Playgroud)

最后,我重新启动了 apache2 Web 服务器:

sudo systemctl restart apache2
Run Code Online (Sandbox Code Playgroud)

就这样。

我希望这有帮助

  • 您还可以通过简单地运行“sudo a2ensite my-website”然后重新启动 apache 来启用站点配置。 (2认同)

Jas*_*Jas 1

事实证明,域名一开始就指向了错误的服务器!这就是显示错误的原因。将域的 A 记录指向正确的服务器后,配置全部正确。