Ubuntu, Apache2, VirtualHosts & websites not working
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I found this article that I followed, we have two websites that are working that we accessed via IP. when it comes to setup the VirtualHosts there seems to be an issue.
I configure the host file to point to the correct internal IP, I am able to ping it. I access the first site and it shows me the HTML I created as a test landing page. When I try the second one, it keeps forcing me to https/443 and just says on Chrome, "This site can't be reached [url]www..com refused to connect.
From the server, I can see data coming from the TCPDump and it looks a little like this:
It might help to have a link to the article you refer to.
This is a shot in the dark, but, if the site(s) have new ip addresses, it can take some time for changes in the DNS record to propagate across the net. Most hosting services will tell you to allow at least 24 hours, but it's usually less.
Are you sure that the hosts file is correct?
Is the computer you're connecting from on the same network as the server?
I don’t see reference to the security certificate within the 443 virtual host definition. 443 connections need a cert.
You are restarting the web server after each change, yes?
What does the access log for each domain site say? How does the working one differ from the non-working one? Oh, you have both sites going to the same logs...I recommend separating log files by domain.
First, we cannot use two different ports in the same configuration file. If you have these two different ports in a single configuration file, then remove from there.
Meanwhile, May I know which two directories you have created for websites?
This is what /etc/apache2/sites-available look like for the respective sites
<-snip->
Having vhosts config files under that directory does not necessarily means that these vhosts are enabled.
You need to run "a2ensite ..." to enable the vhost(s) you want.
BTW, you can use the following command to see what vhosts are enabled in your ubuntu server:
And why are you using tcpdump as the first tool to debug this? Not that tcpdump is a bad idea, far from it, but you should be looking into the apache logs. And if you really use tcpdump, you should be searching for the server name and all that.
As scasey has already pointed out, you're missing the certificates in the https virtual hosts. That means you either haven't restarted the server after making the changes or you apache server isn't working at all after you've tried to restart it, but you just didn't bother to check.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.