Can connect to website with ip but not with domain

I am hosting a website from my home. I am using apache2 and setup a virtual host for my domain. But when I use my domain in my browser it gives (522) error. When I use my home ip it does work.

/etc/hosts:

127.0.0.1 localhost
::1 localhost6.localdomain6 localhost6

The following lines are desirable for IPv6 capable hosts

::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
www.skywars.fun skywars.fun

/etc/apache2/sites-available/skywars.fun.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName skywars.fun
ServerAlias www.skywars.fun
DocumentRoot /var/www/skywars
ErrorLog {APACHE_LOG_DIR}/error.log CustomLog {APACHE_LOG_DIR}/access.log combined

What is going on here?

I have tried messing around with the hosts file without success.

Some other post said it has to do with cloudflare proxying.

Set those hostnames to :grey: until you get that site properly configured with HTTPS, then should will work fine when you set it back to :orange:.

I dont want to setup https since I will be making a one-pager with just information. Is that possible?

Possible, but unwise.

I have been spending an hour trying different tutorials. They all suck hard!!!
Could you link me to a tutorial on how to setup SSL using cloudflare that actually works with ubuntu?

You need to set up SSL on Ubuntu before you can finish the SSL process at Cloudflare. Digital Ocean has good tutorials for this:

I sortof got it working but the website shows weird behaviour on Opera browser.
if I click on “about” in the navbar it goes to “https://www.skywars.funabout
but the “tips” button does work. It works properly on other browsers though.

This issue is caused by certbots http to https redirect but I am not sure how to fix this

Using Cloudflare’s “Always Use HTTPS” setting in Edge Certificates frequently interferes with Certbots, as it won’t let HTTP connections through.

I have that disabled in edge certificates.

I tried enabling it and removing the Rewrite Options in my web configuration but the issue persists

Certbot also has a Cloudflare plugin:
https://certbot-dns-cloudflare.readthedocs.io/en/stable/

Or just use a Cloudflare Origin Certificate:

I tried using the cloudflare origin ca certificates but I don’t know how to acquire the SSLCertificateChainFile

and is the PEM certificate the .crt?

update:
I tried installing cloudflare certificates and now my site is getting 525

update 2:
After following https://websiteforstudents.com/how-to-use-cloudflare-origin-certificates-with-apache2-on-ubuntu-16-04-18-04/
I got it working

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.