apache - 更改 apache2 服务器的 ssl 端口。 (ERR_SSL_PROTOCOL_ERROR)

标签 apache ssl amazon-ec2 https apache2

我正在我的 EC2 实例上开发 apache2 环境。为了安全起见,我想更改 apache2 的 ssl 端口。 我已经通过使用 chrome 浏览器检查页面来确认默认 ssl 端口 443 正在工作。但是在像下面这样修改 ports.conf 之后,我在访问此服务器时遇到错误,ERR_SSL_PROTOCOL_ERROR https://xxxxxxx:18443/

是否有更改ssl端口的设置?

监听端口

$ ss -lnt
State       Recv-Q Send-Q                         Local Address:Port                           Peer Address:Port
LISTEN      0      128                                        *:22                                        *:*
LISTEN      0      64                                         *:7777                                      *:*
LISTEN      0      50                                 127.0.0.1:3306                                      *:*
LISTEN      0      128                                       :::22                                       :::*
LISTEN      0      128                                       :::18443                                    :::*

/etc/apache2/ports.conf

#Listen 80

<IfModule ssl_module>
        Listen 18443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 18443
</IfModule>

环境

  • 操作系统:ubuntu 14.04 服务器(Amazon/EC2 AMI)
  • apache:Apache/2.4.7 (Ubuntu)

EC2 入站安全政策

Custom TCP rule: TCP, 18443, 0.0.0.0/0
Custom UDP rule: UDP, 18443, 0.0.0.0/0

最佳答案

我自己找到了答案。我还需要编辑 default-ssl.conf。所以我总结了设置 ssl 和更改其端口的所有过程。在此示例中,我将 ssl 端口从 443 更改为 18443。

$ sudo apt-get install apache2
$ sudo a2enmod ssl
$ sudo a2ensite default-ssl
$ sudo service apache2 restart
$ ss -lnt
State      Recv-Q Send-Q        Local Address:Port          Peer Address:Port
LISTEN     0      128                      :::443                     :::*
LISTEN     0      128  

然后,尝试更改ssl端口。

$ sudo vi /etc/apache2/ports.conf
<IfModule ssl_module>
        Listen 18443
</IfModule>
<IfModule mod_gnutls.c>
        Listen 18443
</IfModule>

在这个设置中,我使用了default-ssl,所以我也要修改这个文件。

 $ sudo vi /etc/apache2/sites-available/default-ssl.conf
 <IfModule mod_ssl.c>
   <VirtualHost _default_:18443>
   ...

然后,重启apache2就可以访问http://xxxxxx:18443/

$ sudo service apache2 restart

关于apache - 更改 apache2 服务器的 ssl 端口。 (ERR_SSL_PROTOCOL_ERROR),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34304022/

相关文章:

php - 如何检查 php 以什么用户身份运行?

java - Apache ActiveMQ 临时存储限制警告?

security - 加密授权组播

php - 如何避免来自 LinkedIn 的 "HTTP/1.1 999 Request denied"响应?

python - 将文件从 django View 写入静态文件夹(django 通过 apache 2.2 运行): [Errno 2] No such file or directory:

java - tomcat的域问题

ssl - s_client 验证证书失败,但浏览器接受

magento - 不安全地址更改的 fatal error Magento 后端

java - Jar cron 作业未运行(手动运行)

sql - 使用 SES 发送个性化的每周摘要电子邮件?