logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Ubuntu Virtual Host served by Cloudflare is displaying a 521
Author
NikLever



Joined: 27 Dec 2023
Posts: 3
Location: UK, Oldham

PostPosted: Wed 27 Dec '23 11:39    Post subject: Ubuntu Virtual Host served by Cloudflare is displaying a 521 Reply with quote

I am in the process of transferring a number of sites to a new server. I've moved two already and after lots of issues these two are displaying fine on the new server. I'm using Cloudflare and have updated the DNS so the Virtual Host displays the sites from the new server.

At first I update the DocumentRoot in /etc/apache2/sites-available/000-default.conf

For the problem site it then displays fine using the server ip address.

I have done a2ensite and can see the conf file in sites-enabled. My VirtualHost file is

Code:
<VirtualHost *:80>
   
    ServerAdmin webmaster@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html

    <Directory "/var/www/example.com/public_html">
        AllowOverride All
    </Directory>

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

</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

But if I change the Cloudflare DNS I get the 521 Error when trying to access the site using the domain name. If I switch the path in the Virtual Host to /var/www/html. I get the same error.

Not sure why two other sites work using essentially the same VirtualHost conf file, just with changed DocumentRoot, ServerName and Alias.

error.log and access.log don't show anything related to the problem.

Any suggestions.

mod note: changed domain name to exmaple.com
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 27 Dec '23 17:54    Post subject: Reply with quote

Error 521 means that cloudflare can't reach your server.

Code:
Internet<---->CF<---X--->YourRealIP
Back to top
NikLever



Joined: 27 Dec 2023
Posts: 3
Location: UK, Oldham

PostPosted: Wed 27 Dec '23 18:06    Post subject: Reply with quote

Yes, I understand that Cloudflare can't reach the website. The question is why and how to resolve it. As I explained two other sites on the same server with virtually the same VirtualHost conf files are working fine.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 27 Dec '23 18:30    Post subject: Reply with quote

Things might to fix

1. Cloudflare points to the correct real IP
2. if you are using SSL on your server you might check the Encryption Settings from cloudflare
The encryptions modes can be:
- Flexible. All the connections between Cloudflare and your origin are via HTTP. Use this Flexible SSL if you cannot set up an SSL certificate for your domain.
- Full. Cloudflare connects to the origin server using either HTTP or HTTPS, depending on the visitor’s request. Choose the Full SSL mode if you have an SSL certification.
- Strict. Similar to Full, visitors can decide which protocol to use. However, this mode has more requirements for origin certificates.
3. sites-available is not sites-enabled. Is there a correct symlink to the new vhost?
4. restart apache to get the vhosts working.
Back to top
NikLever



Joined: 27 Dec 2023
Posts: 3
Location: UK, Oldham

PostPosted: Wed 27 Dec '23 20:29    Post subject: Reply with quote

It looks like it is the Cloudflare encryption mode. Many thanks.
Back to top


Reply to topic   Topic: Ubuntu Virtual Host served by Cloudflare is displaying a 521 View previous topic :: View next topic
Post new topic   Forum Index -> Apache