#StackBounty: #apache #dns Apache : www.fakedomain.com works not https://fakedomain.com

Bounty: 50

I have apache server serving fakedomain.com with following vhost conf.

<VirtualHost *:80>
    DocumentRoot /var/www/master/public_html
    ServerName www.fakedomain.com
    ServerAlias fakedomain.com
    ServerPath /var/www/master/public_html
    CustomLog /var/log/apache2/fakedomain/master-access.log combined
    ErrorLog /var/log/apache2/fakedomain/master-error.log
    #LogLevel debug

      <Directory /var/www/master/public_html>
            Options -Indexes +FollowSymLinks
            Order Allow,Deny
            Allow from All
      </Directory>
    RewriteEngine On
    RewriteRule ^(/www/.*) /www/fakedomain.com$1
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule .* https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_URI}  (?i)(.*)(.jpe?g|.png)$
    RewriteCond %{DOCUMENT_ROOT}%1.webp -f
    RewriteRule (?i)(.*)(.jpe?g|.png)$ %1.webp [L,T=image/webp,R]
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/master/public_html
    ServerName www.fakedomain.com
    ServerAlias fakedomain.com
    ServerPath /var/www/master/public_html
    CustomLog /var/log/apache2/fakedomain/master-access.log combined
    ErrorLog /var/log/apache2/fakedomain/master-error.log

    <Directory /var/www/master/public_html>
        Options -Indexes +FollowSymLinks
            Order Allow,Deny
            Allow from All
    </Directory>

    RewriteEngine On
    RewriteRule ^(/www/.*) /www/fakedomain.com$1
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_URI}  (?i)(.*)(.jpe?g|.png)$
    RewriteCond %{DOCUMENT_ROOT}%1.webp -f
    RewriteRule (?i)(.*)(.jpe?g|.png)$ %1.webp [L,T=image/webp,R]
    SSLEngine On
    ServerSignature On
    SSLCertificateFile /etc/ssl/certs/star_fakedomain_com_05_2020.crt
    SSLCertificateKeyFile /etc/ssl/private/star_fakedomain_com.key
    SSLCertificateChainFIle /etc/ssl/certs/DigiCertCA.crt
</VirtualHost>

I am able to access www.fakedomain.com but not https://fakedomain.com and gets ERR_CONNECTION_TIMED_OUT error

This apache running on ec2 and behind classic ELB. www.fakedomain.com & fakedomain.com are A record in DYN dns.

Everything works fine when DNS directly pointed to
I have DNS record for www.fakedomain.com & fakedomain.com. Also tried to swap ServerName & ServerAlias, but no luck. Anyone point out whats wrong here ?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.