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: Help with Virtual Hosts Page 1, 2  Next
Author
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 05 Jun '14 22:09    Post subject: Help with Virtual Hosts Reply with quote

Hey guys,

I have my Apache 2.4.9 for Windows with multiple Virtual Hosts, the main one is configure like this:

Code:
NameVirtualHost vhost1.domain.org:80
<VirtualHost vhost1.domain.org:80>
  ServerName vhost1.domain.org
  DocumentRoot "C:/Apache24/htdocs"
  ServerAdmin techsupport@domain.org
  # ErrorLog "logs/vhost1.domain.org-error.log"
  # CustomLog "logs/vhost1.domain.org-access.log" common
</VirtualHost>


The rest like this:

Code:
NameVirtualHost vhost2.domain.org:80
<VirtualHost vhost2.domain.org:80>
  ServerName vhost2.domain.org
  DocumentRoot "C:/Apache24/htdocs/vhost2"
  ServerAdmin techsupport@domain.org
  # ErrorLog "logs/vhost2.domain.org-error.log"
  # CustomLog "logs/vhost2.domain.org-access.log" common
</VirtualHost>


There is no *:80 anywhere and still when I go to any vhost it always load the main one.

What else do I need to check?

Thanks,

PS, the error log doesn't show anything.[/quote]


Last edited by jfha73 on Mon 09 Jun '14 22:16; edited 1 time in total
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 05 Jun '14 22:26    Post subject: Reply with quote

Never mind,

I noticed that in Apache 2.4 call to extra/httpd-vhost.conf was commented
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 05 Jun '14 22:56    Post subject: Reply with quote

I spoke too soon.

2 of the vhosts work fine, but the rest point to one of the working ones. not even the main one anymore.

Any ideas?
Back to top
jraute



Joined: 13 Sep 2013
Posts: 188
Location: Rheinland, Germany

PostPosted: Fri 06 Jun '14 15:14    Post subject: Reply with quote

You need a NameVirtualHost *:80 entry which tells apache that you're going to use name-based virtual hosts.

Code:
NameVirtualHost *:80

 <VirtualHost *:80>
     DocumentRoot /www/abc
     ServerName www.abc.com
 </VirtualHost>

 <VirtualHost *:80>
     DocumentRoot /www/xyz
     ServerName www.xyz.com
 </VirtualHost>


Last edited by jraute on Fri 06 Jun '14 16:27; edited 2 times in total
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Fri 06 Jun '14 15:35    Post subject: Reply with quote

Yeah, I figured that out too, but instead of creating that VirtualHost, I just changed the ServerName line in httpd.conf to the main one and started working.

I found something else though.

After a few minutes of having everything working, suddenly Apache stops working, NOT crashing, just no computer can access it, the server says it's running, but nobody can see anything.

This behavior is Using Apache 2.4.9 x64 on Windows Server 2012 R2, I have not seen it on 2012 or 2008 R2 where I have a few more running just nice.

Can somebody run the tests needed to see if this is just me or Apache 2.4.9 x64 on Windows Server 2012 R2

Thanks,
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Mon 09 Jun '14 16:20    Post subject: Reply with quote

I don't get it, even after adding the default host and *:80 to the virtual hosts, it keeps doing the same, even in Windows Server 2008 R2, I don't know what else to do, the Apache 2.2 that I had running for years in Windows 2008 R2 was working just fine with all the virtual host it had (5 of them) but now that I got a new server with 2012 R2 and 2008 R2 Apache 2.4 doesn't want to work with Virtual Hosts anymore, has anybody else encounter this problem or it is just me?
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Tue 10 Jun '14 0:59    Post subject: Reply with quote

Is anybody reading this forum?

I just tested it on my machine (Windows 7 x64) wiath Apache 2.4.9 x64, uncommented the vhosts line and configured 3 Virtual Hosts on it including *:80 and I'm getting similar results (Virtual Hosts not working properly).

I'm starting to think there is something fundamentally wrong with Apache 2.4 for Windows handling multiple (more than 2) Virtual Hosts.

Hey guys, I need somebody to run this test so I can make a bug report.

Thanks,
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 10 Jun '14 4:08    Post subject: Reply with quote

No there is nothing wrong with 2.4.9, many of us have multiple vhosts and it works for us. Chances are you have not configure properly. A usual mistake is not duplicating the main host (in httpd.conf) as your first vhost.

httpd.conf
ServerName www.main.com
DocumentRoot \www\main


httpd-vhosts.conf

<VirtualHost *:80>
# This is also a catch-all host
DocumentRoot \www\main
</VirtualHost>

<VirtualHost *:80>
DocumentRoot \www\second
ServerName www.second.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot \www\third
ServerName www.third.com
</VirtualHost>

of course you need to have <Directory> containers allowing access for these
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Tue 10 Jun '14 18:36    Post subject: Reply with quote

Thanks,

Putting the <Directory> lines inside each virtual host is working, now the only thing is that when I run "httpd -S" it says that my default server is not my real default (main), I even added _default_:80 as one of my virtual hosts and it still says it's another one of the virtual hosts in it.

How can I make my main host (the one that lands in C:\Apache24\htdocs) the default?

Thanks.
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Tue 10 Jun '14 19:12    Post subject: Reply with quote

I just tried what worked on my computer into the live server and it just kept spinning, no error, it just doesn't show anything, I wonder if it has something to do with the SSL Virtual hosts.

Do I have to put their directories to each virtual host with SSL?

It's the only thing that's different from my machine and the live server.

Thanks.
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Tue 10 Jun '14 19:25    Post subject: Reply with quote

Nope, I added the directories to each one of the SSL virtual hosts and did the same thing.

This is getting frustrating, I never had this problem with Apache 2.2
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Tue 10 Jun '14 21:07    Post subject: Reply with quote

I ran another test,

I switched all :80 to :8080 and it doesn't stay loading for the longest, but if I changed it back to :80 it behaves like that.

WEIRD because it doesn't do that on my Windows 7 machine.
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 12 Jun '14 15:26    Post subject: Reply with quote

Hey guys:

I replaced all <virtualhost name.domain.org:80> for <virtualhost *:80> and left just the servename in each with their names, but again, it works only when I put *:8080, when I change that to *:80 I get a "This page cannot be displayed" message.

What can cause this behavior?

Please guys, I don't want to use IIS for this.

Thanks,
Back to top
jraute



Joined: 13 Sep 2013
Posts: 188
Location: Rheinland, Germany

PostPosted: Thu 12 Jun '14 17:43    Post subject: Reply with quote

Sorry, but this post is getting a bit confusing.

Can you please describe your configuration and on which computer the problems occur.

You have told us about a server and your pc and reading all the posts don't help me to discover what is working now and what is not working.

Thanks for your understanding
JR
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 12 Jun '14 21:22    Post subject: Reply with quote

This is the thing:

I have a Windows Server 2008 R2 using Apache 2.4.9 x64 that has 5 virtual hosts configured, when I start the Apache server, they all start to work for a little while, after navigating my server for a few minutes all the virtual hosts start to misbehave by just keeping the client browser say waiting for server and nothing shows.

What I was saying about my pc is that I ran a test on it with 3 virtual hosts and they never showed this behavior.

I tried everything in this topic to try to fix it, but it still happens.

The way I have my server right now is configured every virtual host as follows:

Code:

<VirtualHost *:80>
    ServerName name.domain.org
    DocumentRoot "D:/Apache24/htdocs/<host>"
    ...
    ...
</VirtualHost>


I don't know why this is happening and Apache has nothing in the error log to tell me.

Any ideas?
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 12 Jun '14 22:17    Post subject: My vhosts file Reply with quote

This is my vhosts file to see if you can find the problem with it.

Code:

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs"
    ServerName intranet.domain.org
    ServerAlias intranet.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>

<VirtualHost _default_:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs"
    ServerName intranet.domain.org
   ServerAlias intranet.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs/helpdesk"
    ServerName techsupport.domain.org
    ServerAlias techsupport.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs/pool"
    ServerName supportpool.domain.org
    ServerAlias supportpool.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs/fusion"
    ServerName helpdesk.domain.org
    ServerAlias helpdesk.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin techsupport@domain.org
    DocumentRoot "D:/Apache24/htdocs/sharepoint"
    ServerName sharepoint.domain.org
    ServerAlias sharepoint.domain.org
    ErrorLog "logs/error.log"
</VirtualHost>
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Thu 12 Jun '14 23:07    Post subject: Reply with quote

Also, with that same conf file if I change :80 to :8080 and in httpd.conf change Listen 80 to Listen 8080 Everything works like it supposed to work, I get no delays in pages, no clients saying waiting for server or any other problem, this is the weird part.
Back to top
jraute



Joined: 13 Sep 2013
Posts: 188
Location: Rheinland, Germany

PostPosted: Fri 13 Jun '14 10:26    Post subject: Reply with quote

Hi!

1. i miss the NameVirtualHost *:80 entry.
2. did you insert the following code in httpd.conf?
Code:
   EnableMMAP Off
   EnableSendfile Off

   AcceptFilter http none
   AcceptFilter https none

3. if you try to connect locally (directly from the computer) via port 80 - is that working?
4. is the server placed in a dmz and do you use a proxy-configuration?
5. firewall?

Greets
JR
Back to top
jfha73



Joined: 18 Aug 2011
Posts: 62
Location: New York

PostPosted: Fri 13 Jun '14 15:13    Post subject: Reply with quote

1. NameVirtualHost is deprecated in 2.4

2. EnableMMAP is off EnableSendfile is off by default in 2.4

The 2 filters are not set, what do they do?

3. No, same issue

4,5. No Firewall, no proxy, it's on sort of like a dmz.

Also, I don't think it's blockage, because when I disable Apache and turn on IIS, it works just fine in port 80.

And before you ask, yes, I do stop IIS before I turn on Apache.

Thanks.
Back to top
jraute



Joined: 13 Sep 2013
Posts: 188
Location: Rheinland, Germany

PostPosted: Fri 13 Jun '14 16:49    Post subject: Reply with quote

Ok.
Well it seems something very special.
Honestly spoken, i don't have any further ideas.

Acceptfilter http none is a directive that activates/deactivates system-specific optimization for listening sockets.

In a windows environment you typically use
Code:
Acceptfilter http none
Acceptfilter https none


For Linux you use
Code:
Acceptfilter http data
Acceptfilter https data


For freebsd you use
Code:
AcceptFilter http httpready
AcceptFilter https dataready


Ok, last thing you can try and sometimes it helps, install a fresh apache completely new, but i fear that it won't help.
If 8080 works and 80 not, there must be a code-line which affects the behaviour.
Back to top


Reply to topic   Topic: Help with Virtual Hosts View previous topic :: View next topic
Post new topic   Forum Index -> Apache Page 1, 2  Next