1

Where's the right place to put my vhost config for SSL

/opt/lamp/etc/extra/httpd-vhosts.conf or in httpd.conf ?

Currently, my configuration for SSL is located in httpd-vhosts.conf

<VirtualHost *:1223>
DocumentRoot "/opt/lampp/htdocs/api_tk_b/public"
DirectoryIndex index.php
ServerName api-b.mydomain.com
ServerAlias api-b.mydomain.com
ServerAdmin *.mydomain.com
#SSLEngine on
#SSLCertificateFile "/opt/lampp/htdocs/crt/gd.crt"
#SSLCertificateKeyFile "/opt/lampp/htdocs/crt/mydomain.key"
#SSLCACertificateFile "/opt/lampp/htdocs/crt/gd-bundle.crt"
<Directory "/opt/lampp/htdocs/api_tk_b/public">
    Options All
    AllowOverride All
    Require all granted
</Directory>
ErrorLog "logs/api_b-error_log"
CustomLog "logs/api_b-access_log" common
</VirtualHost>

But it's not working, I don't think the error is in my crt , key and bundle maybe there's something I need to do first before doing this?

I'm using GoDaddy as of now

My Update

This is my update as of now.

First, Why *:1223 because I have multiple projects I have in the server and uses sub-domain but these projects are not using ssl that's why I tried to use 1223 to make it work too.

api-b.mydomain.com

is now working if I comment the SSL configuration

and When I comment out the SSL configuration

the apache fail to restart.

It keeps running but, when I try to access on web

using this link: https://api-b.mydomain.com the web says

This site can’t be reached api-b.mydomain.com refused to connect.

Note:

My key folder is exists and my key files are not empty.

This configuration code is working in Windows but not in linux is there any configuration do I need to do?

Also

If I access the error.log, it's not empty but there's no connected issue occured in the log related to my api and the api-b-error.log is empty too

/opt/lampp/etc/extra/httpd-vhosts.conf api-a.mydomain.com

1 Answers1

1

This VirtualHost is listening on Port 80 only. You need to change it to 443:

<VirtualHost *:443>

Don't forget the Listen 443 directive which is most probably somewhere else in the Apache config.

To be clear: You need two VirtualHost directives. One for Port 80 and one for port 443. The 443 must be the only one containing the SSL directives. The rest can be identical (or 80 can contain only a redirect to 443).

Gerald Schneider
  • 26,582
  • 8
  • 65
  • 97