Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 552
jef Avatar asked Feb 08 '23 07:02

jef


1 Answers

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, try 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 used 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
like image 50
jef Avatar answered Feb 15 '23 23:02

jef