简体   繁体   中英

Change ssl port of apache2 server. (ERR_SSL_PROTOCOL_ERROR)

I'm developing apache2 environment on my EC2 instance. For security, I want to change ssl port of apache2. I've already confirmed default ssl port 443 was working by checking page with chrome browser. But after modifying ports.conf like below, I've got an error, ERR_SSL_PROTOCOL_ERROR when accessing this server like https://xxxxxxx:18443/

Are there any settings for changing ssl port?

listening ports

$ 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>

environment

  • OS: ubuntu 14.04 server (Amazon/EC2 AMI)
  • apache: Apache/2.4.7 (Ubuntu)

EC2 inbound security policy

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

I found an answer by myself. I also need to edit default-ssl.conf. So I summarize all procedures to set up ssl and changing its port. In this example, I change ssl port to 18443 from 443.

$ 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  

Then, trying to change ssl port.

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

In this setting, I use default-ssl, so I also have to modify this file.

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

Then, you restart apache2 and you can access http://xxxxxx:18443/

$ sudo service apache2 restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM