Virtual server on virtualmin keeps redirecting to wrong website - apache

I have created a virtual server say aaa.com but when I access the site (via editing my hosts file on Windows 7, cos I have a live aaa.com running on the Internet), it brings me to my other virtual server's site I have, like bbb.com
Why is that? I don't have any redirection running. Not in my script files (like html or php) and no redirection set under "Server Configurations" -> "Website Redirects" and none at "Services" -> "Click Configure Website" -> "Aliases and Redirects." The only script files I have are fresh new WordPress installation files (under home/aaa/public_html).
How do I fix this?

Mullazman is right (thanks!). I have just had this problem after enabling the SSL on the domain A. Then, all the domains in the same installation were pointing to A.
I fixed it by editing the file located in /etc/apache2/sites-enabled/A.conf and changing the first line:
Wrong line -> <VirtualHost A.B.C.D:80>
Correct line -> <VirtualHost *:80>

Had the same issue. For anyone interested it's because I had at the header of my sites-enables/aaa.com.conf which was picking up all requests and send them to the first host.
Change it to and it started directing traffic to the correct virtual hosts.
It was triggered when I enabled SSL on aaa.com, it for some reason re-wrote the config file to use IP based filtering not domain name

Try to delete browser cache with CTRL+F5,
then try again. If that doesn't help, check virtualhost configuration files -maybe there lies the problem.

The solution I found
I had the same problem ...
And I ended up with a lot of doubts ...
And I searched for a SOLUTION for this case, I hope to help ...
1 - Should the BIND have an external or internal IP in the domain? I use only one IP for all servers, and in BIND all domains are with external IP. (The question is whether it should be external or internal IP).
R = Yes, you must configure the internal IP in Virtualmin, prefer to edit the file. Only in localhost you should have 127.0.0.1
2 - Would NGINX have any configuration? How to remove IP and just put (listen *: 80) instead of (listen 288.218.198.981:80)
R = This configuration was changed but then I had problems with DNS and I returned to use the INTERNAL IP (not the localhost) ... Normally this IP starts as: 10.1xx.xx.xx
But which configuration would work in general?
Restart these steps ...
If you still have an error ...
Back up ... And in Virtualmin settings ...
Edit Virtual Server >> Activate Features >>
Uncheck NGINX, BIND, NGINX SSL.
He will ask for confirmation and click to confirm.
After this process is completed, return to the same option and reschedule ...
This will make it delete the old ones and put a new one.
(This works great for those who changed hosting and has old settings).
If you are importing a backup. Do not select the DNS and NGINX option ...
One tip is to create Virtual Server {your domain / site} First of all ...
And only then only import directories and databases ...
So you will not have problems with DNS and wrong redirects ...
Update
This also occurs when the SSL certificate is not issued correctly.
Folder permissions are incorrect.
Chmod 0755 folders
0644 Files

SOLUTION!!!
Cheap workaround let us say our domain is domain.xyz
Under the BindDNS Master Zone for domain.xyz create a cname record I believe it is listed in webmin as Name Alias and name it 000.domain.xyz
Under apache create a virtual server with the name 000.domain.xyz and make sure it has the same directory as domain.xyz
After this is done you are golden all your websites will come up as they should!
Is it proper well maybe not.
Does it work well like a charm of course otherwise I wouldn't be sharing for some reason the way the severs are listed it defaults to the first on the list well that'll fix that there should be a method of pinning the servers or doing something to prevent such a thing from happening what a pain in the rear I spent a full day dumbfounded thinking what in the world is going on I am losing my touch.
If this helps give a like if its wrong apologies all I know is that it works.
Read the thread.
Many folks claim this is an SSL thing.
Zero people have eluded to the true method of fixing it or the proper directions to do so or if they did I'm too blind to see it.
The guy below me commenting hrmmm... Yeah browser caches for my website didn't exist on my devices I tried them on to verify that was not the problem. But yes this is a typical problem with a lot of things indeed. It is the only reason I have several browsers on my PC actually for that reason. For a while there there were pages that chrome would function with that IE wouldn't or Firefox would best them both. Not to mention cache is always a pita its always usually one of my steps in troubleshooting any issues with web pages. I'll even try openDNS or other DNS servers.
But holy cats I can't believe how fast DNS just updates once you got things set it makes me wonder if there is a lot of fudge in propigation when you purchase hosting being "24 -48 hours" I think there is a lot of fudge in those numbers after my experiences trying to figure out what was causing the issue here. Some servers struggle yes but for the most part it was pretty instant for me.

In my case it happened after creating SSL certificate, I forgot to do:
Edit Virtual Server -> Enable Apache SSL Website

Related

Use Windows 2016 server with Xampp to host more than 1 website

I have tried all kinds of things, read all answers, and configured the bananas out of it, but I cannot seem to get the following working:
A windows 2016 server with XAMPP, to host more websites than 1.
What have I done:
I have altered the httpd-vhosts.conf as described all over the web with allowing NameVirtualHost, and setting up virtual host with documentroot, servername etc.
I have pointed a domain with the a-record to this server
installed the latest XAMPP release to date
changed the windows hosts file, as described everywhere (127.0.0.1 domainname.com)
What works:
I can get the domain working on my server's browser. When I enter the specific domainname.com it shows the hello world page I made in the specified folder. The domain resolves and shows the page that is in de directory accordingly
Besides that, the localhost of apache is also working, I have 2 sites working, but only on the browser of the server, on the machine itself.
What does not work:
Only 1 thing. when I want to access the domain from any other machine than the server (from outside so to say), it will not work, but when I ping the domain on my home-pc it resolves to the server.
I am at a loss. Been at this for hours, and beginning to question if it is even possible.
Can anyone tell me what I am doing wrong here, or if it is even possible to have more than 1 website to work on XAMPP and resolve form the outside?
Thank you in advance.
It was windows firewall that stopped all inbound connections. I finally figured it out!

When one domain is being hit, another is loaded

I just removed some virtual hosts and restored them from backup.
I noticed that no matter what domain from the following i hit:
kidsclubpaidika.gr
ypsilandio.gr
varsa.gr
always my hit gets instantly redirected to domain kidsclubpaidika.grinstead.
Why is this happening?
I use Webmin/virtualmin btw.
here is my relevant httpd.conf https://pastebin.com/vzwbzTh8
There's a FAQ about this kind of problem: https://www.virtualmin.com/documentation/web/troubleshooting#toc-the-wrong-site-shows-up-V5JtxdKg
The short description of the problem is that when combining VirtualHosts that use IP addresses and *, the way Apache decides what to show is unintuitive (to put it mildly). Mixing * and IP-based VirtualHosts is, thus, not recommended. So, find the virtual hosts that use * and switch them to IPs, or find all the IPs and switch them to *. Don't mix and match. I usually recommend using IPs, but either works, as long as you only have one IP.
If you have a default site (e.g. 000-default on Ubuntu/Debian), disable it. In a virtual hosting environment, "default" doesn't really have the same meaning and can lead to confusing results. The Virtualmin installer will do that for you, but doing a dist upgrade will lead to config files being overwritten and that site being re-enabled.

Bitnami Trac apache set domain name

I recently installed Bitnami trac and now I want to access it using my domain name.
I've made the necessary changes to the apache config file (httpd.conf) found in C:\Bitnami\trac-1.0.5-0\apache2\conf\ directory. I've installed trac in port 8080.
So this is the only change I made.
ServerName trac.mydomain.com:8080
I had trac in another server before, and that time also this was the only change I made to get my domain work with it. But this time it doesn't work.
Can somebody please tell me where I've missed? Do I have to update any other place?
According to your comment, you can access the server fine by using the IP address, but can't access it at all when using the domain name. This sounds like it might not be related to Trac at all. Here are a couple of things to try:
Run "nslookup your-domain-name.com". You should get a result that says "Addresses:" and lists your server's IP address. If you don't (or if you get a "Non-existent domain" error), then your DNS server isn't mapping your domain name to your IP address correctly.
Look through Apache's various log files on your server and see if there is any evidence of your request ever reaching your server. Whenever I do this, I first change LogLevel to debug in the Apache config files so that I get as much output as possible (restart Apache after changing the config file). If a 'debug'-level log doesn't even show that Apache saw the request, then something between your server and your local system is causing problems (a firewall perhaps). If the Apache logs do show that the request made it through, then the problem is likely an Apache configuration problem and the log output should provide hints as to how to continue.
Try connecting via VPN and then accessing your server by domain name (not IP address). If you can access the server by IP but not by name, then the server may not know its own domain name.
Bitnami developer here. By default bitnami installations accept petitions from any IP so you don't have to set the ServerName.
Although, if you want your page to be accessible using trac.yourdomain.com, you should consider using apache virtualHosts, could you try to follow this documentation page?
https://wiki.bitnami.com/Components/Apache#How_to_create_a_Virtual_Host.3f

Trouble setting up a subdomain on a VPS under Ubuntu and Apache

I'm a complete newbie when it comes to servers, so I need some help. Basically, I want to have a subdomain on my VPS. I'm not too concerned where the files reside, though of course I would like them separated if possible.
I found a guide to doing this that basically sums the procedure up in five steps:
Create directories to host the content of a new virtual site.
Make a copy of the /etc/apache2/sites-available/defaults file with a site appropriate name.
Change the two /var/www/ entries to the actual directory of the new site.
Add the ServerName line with the real domain name you will be hosting.
Use a2ensite to enable the new site, and finally reload Apache2 so it knows about the new site
I tried all of this, but I can't get it to work. I didn't get any errors at any point during this process, but when I enter the address with the subdomain into my browser, I get a "Server not found" error.
The company that hosts my VPS has an admin page where I can set up subdomains. Stupid question: do I have to do reconfigure the DNS records or something while doing this, or is it likely that the problem is caused by something else?
Additional note: I followed a guide on howtoforge.com when setting up the server, which in hindsight may not have been the brightest move on my part. It is possible that I made a mistake there that is somehow affecting me now?
Assuming you've setup the subdomain correctly in your VPS' admin page, the only thing left to check here is that you've actually created the subdomain in your DNS administration page (have you?). For example, I use afraid.org to manage my DNS records and to add a subdomain, it's essentially:
Type: A
Subdomain: sparky
Domain: example.com
Destination: 120.34.2.3 (this would be your VPS' IP address)
In general, you add a (sub)domain by:
sparky.example.com A 120.34.2.3
Please keep in mind that you want to add an A record (this is important!).

How can I test a comet ajax site on a single host and work around browser simultaneous connection limit?

I am using the comet long-polling technique with apache, php, jquery.
I've got a basic comet update running and it works great. I'm now attempting to build a more complex comet script, and I want a better way to debug.
My comet scripts use $.ajax() with a long timeout, and the server side just sleeps until it either runs up to the timeout or has an event to send to the client. The comet requests go to a different subdomain than the main ajax requests.
For normal pages I edit and test on a linux laptop. I've got apache, mysql, and php with a test database and mirror image of the site. I can edit, save, and see the changes with no upload step. For the comet stuff I've been having to upload to a server to test. This requires me to set up a few fake servers, but mostly it requires me to upload changed files for each test. I've got a mostly automatic upload script, but it's still too slow.
The problem testing locally is the long timeout. The browser won't open another connection to the same server while the comet request is still open. I don't have a subdomain locally so I have all the requests going to the same server so they basically block each other.
I've tried a number of things to make this work and none really do it. I tried first to change my browser setting for number of simultaneous connections. This didn't work in firefox on linux, and I didn't find anything about changing this limit on other browsers.
I tried setting my hosts file to give me two names that map to my ip address. Then I tried configuring VirtualHost conf directives in apache, but that didn't work. I think because apache is looking for an actual dns server to tell it the hostname, not just my /etc/hosts file. Maybe I can run a local dns server to fool apache into thinking my box has two names, but that just seems like a real long way around this problem.
So, does anyone have an idea of how to make this work on one ip address/host?
I'm new to the comet thing, so maybe I've just got the wrong idea about something. Maybe this isn't even possible. Either way, it's time to just ask if this is already a solved problem.
It really should be possible to use /etc/hosts to fool Apache. It certainly does work on Ubuntu Hardy with Apache 2.2.
Try to give different hostname to you local address. Simply add a line like this to /etc/hosts:
127.0.0.1 a.example.com b.example.com c.example.com d.example.com
(Note: use a tab after IP)
Validate this with a ping
ping a.example.com
In you apache configuration, you may use a wildcard alias together with a named virtual host:
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
## snip ##
<VirtualHost>
Instead of using example.com, you might want to use something that's under your control. I use local subdomain of our company's domain (i.e. something.local.molindo.at).
Now you can use different subdomains for your test, each with its own limitation on concurrent connections.
You may need to restart your browser to get this working.
I have made something similar and my hosting gives my max queries limit reached which actually should not happen. But I have read that if my php code is in infinite loop.. ie the sleep mode the hosting detects it and makes db connection user as to be using more queries than allowed. That is alot to presume but I have found a solution to that with same speculations.