skip to Main Content

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 or http://fakedomain.com 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.

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 ?

2

Answers


  1. Do you have a self signed cert or godaddy /paid cert?
    One more thing is you have redirect on configuration.

     RewriteEngine On
        RewriteRule ^(/www/.*) /www/fakedomain.com$1
        RewriteCond %{HTTPS} !=on
        RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    You can remove all these lines for testing purpose and then it will work with www and non www
    it will show cert warning if it i sself signed.

    Login or Signup to reply.
  2. "Sorry i can’t post comment i don’t have enough reputation "

    I have tested your configuration in my environnement and it works for me , i can access with www and without it.

    can you try nslookup http://www.fakedomain.com
    and nsllookup fakedomain.com

    it may be a dns propagation problem, or your dns cache is stale with high ttl , or you entered the wrong ip for fakedomain.com

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search