1

This is a hard question to google, or even title.

I can hit my Wordpress site successfully using this:

http://www.example.com/

https://www.example.com/

https://example.com/

But this fails:

http://example.com/

If you try to hit the domain from this address, you see a blue DigitalOcean-branded web page, with a picture of a shark and the following error: "Please log into your droplet via SSH to configure your LAMP installation."

I have a DigitalOcean droplet running Ubuntu 16.04 with Apache 2 and several domains. One of the domains has a Wordpress site that was migrated over from another host. The domain is configured the same as all my other domains, including a certificate installed via letsencrypt.

I do not believe my problem is with the certificate. I believe the problem has to do with Wordpress, because the other sites on my server are working just fine in all 4 conditions (http:// and https:// and www and non-www)

Here is my (anonymized) .conf file:

    <VirtualHost *:80>
    ServerAdmin XXXX@gmail.com
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/www/example
    <Directory />
            Options FollowSymLinks
            AllowOverride All
    </Directory>
    <Directory /var/www/example>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    <IfModule mod_dir.c>
        DirectoryIndex index.php index.pl index.cgi index.html index.xh$
    </IfModule>

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

and here is my .htaccess folder inside of /var/www/example

        # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
#test
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
# END WordPress

and here are my DNS settings, pasted and anonymized:

        CNAME   
ftp.example.com is an alias of example.com. 

A   
example.com directs to 159.65.36.136

CNAME
www.example.com is an alias of example.com. 

NS  
example.com directs to ns1.digitalocean.com.    

NS  
example.com directs to ns2.digitalocean.com.    

NS  
example.com directs to ns3.digitalocean.com.    

and here is my output of apache2ctl -S

            VirtualHost configuration:
*:443                  is a NameVirtualHost
        default server othersite1.com (/etc/apache2/sites-enabled/othersite1.com-le-ssl.conf:2)
        port 443 namevhost othersite1.com (/etc/apache2/sites-enabled/othersite1.com-le-ssl.conf:2)
                alias www.othersite1.com
        port 443 namevhost othersite2.co (/etc/apache2/sites-enabled/othersite2.co-le-ssl.conf:2)
                alias www.othersite2.co
        port 443 namevhost example.com (/etc/apache2/sites-enabled/example.com-le-ssl.conf:2)
                alias www.example.com
        port 443 namevhost othersite3.com (/etc/apache2/sites-enabled/othersite3.com-le-ssl.conf:2)
                alias www.othersite3.com
        port 443 namevhost othersite4.com (/etc/apache2/sites-enabled/othersite4.com-le-ssl.conf:2)
                alias www.othersite4.com
        port 443 namevhost othersite5.net (/etc/apache2/sites-enabled/othersite5.net-le-ssl.conf:2)
                alias www.othersite5.net
        port 443 namevhost othersite6.com (/etc/apache2/sites-enabled/othersite6.com-le-ssl.conf:2)
                alias www.othersite6.com
*:80                   is a NameVirtualHost
        default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
        port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)
        port 80 namevhost othersite1.com (/etc/apache2/sites-enabled/othersite1.com.conf:1)
                alias www.othersite1.com
        port 80 namevhost othersite2.co (/etc/apache2/sites-enabled/othersite2.co.conf:1)
                alias www.othersite2.co
        port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
                alias www.example.com
        port 80 namevhost othersite3.com (/etc/apache2/sites-enabled/othersite3.com.conf:1)
                alias www.othersite3.com
        port 80 namevhost othersite4.com (/etc/apache2/sites-enabled/othersite4.com.conf:1)
                alias www.othersite4.com
        port 80 namevhost othersite5.net (/etc/apache2/sites-enabled/othersite5.net.conf:1)
                alias www.othersite5.net
        port 80 namevhost othersite6.com (/etc/apache2/sites-enabled/othersite6.com.conf:1)
                alias www.othersite6.com
    ServerRoot: "/etc/apache2"
    Main DocumentRoot: "/var/www/html"
    Main ErrorLog: "/var/log/apache2/error.log"
    Mutex rewrite-map: using_defaults
    Mutex ssl-stapling-refresh: using_defaults
    Mutex ssl-stapling: using_defaults
    Mutex ssl-cache: using_defaults
    Mutex default: dir="/var/lock/apache2" mechanism=fcntl 
    Mutex mpm-accept: using_defaults
    Mutex watchdog-callback: using_defaults
    PidFile: "/var/run/apache2/apache2.pid"
    Define: DUMP_VHOSTS
    Define: DUMP_RUN_CFG
    User: name="www-data" id=33
    Group: name="www-data" id=33
  • Please define "does not work". Actual error messages are always useful. – Gerald Schneider Mar 9 '18 at 15:38
  • lol @GeraldSchneider I knew I was missing something crucial. "Doesn't work" shows me a DigitalOcean-branded screen with the following error: "Please log into your droplet via SSH to configure your LAMP installation." – Tim Mar 9 '18 at 15:48
1

Possibility #1

It looks like your default VirtualHost for *:80, using the config file 000-default.conf is matching namevhost example.com at the top of the output... ;

VirtualHost configuration:
    default server example.com (/etc/apache2/sites-enabled/000-default.conf:1)
    port 80 namevhost example.com (/etc/apache2/sites-enabled/000-default.conf:1)

whereas, you want it to match here;

    port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
    alias www.example.com

What's probably happening is that the page with the text "Please log into your droplet via SSH to configure your LAMP installation." is the default content from /var/www/html.

So I would try removing the /etc/apache2/sites-enabled/000-default.conf and ensuring that the example.com is matching the correct VHost.

Possibility #2

Check your settings in wp-config.php, it should match what your redirects are ultimately pointing to;

define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');

This sometimes causes problems with wordpress, when it doesn't match what apache wants.

Further troubleshooting

The other thing is that you have pasted config for a http://example.com:80/ site;

 <VirtualHost *:80>
ServerName example.com 
...
</VirtualHost>

However the rewrite rule looks like it would bounce every request to https://

RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

So we'd probably need to see the https config as well.

Also, you should probably paste the output of access.log and error.log pertaining to one specific request, to see what redirects actually happened.

Also, if you still can't see the problem, you can turn on rewrite logging;

 LogLevel alert rewrite:trace3

and then trace the log for requests;

tail -f error_log|fgrep '[rewrite:' 
  • When you say "try removing the /etc/apache2/sites-enabled/000-default.conf" do you mean actually removing the 000-default.conf file? Or something else? – Tim Mar 10 '18 at 12:56
  • you can use a2dissite to disable it then restart apache. – FizxMike Mar 10 '18 at 14:45
  • Possibility #1 seems like it was the problem. To fix my problem, I used a2dissite 000-default. Then a2dissite example.com and a2dissite example.com-le-ssl. Then I restarted and reloaded apache. Then I re-enabled my site with a2ensite example.com and a2ensite example.com-le-ssl and now everything is pointing the right place. Note, I had to disable and re-enable example.com — just disabling 000-default caused the browser to point example.com to an entirely different folder on my system. – Tim Mar 12 '18 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.