Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: virtual host --> localhost overrides external IP |
|
Author |
|
RighTeouS84
Joined: 23 Jul 2010 Posts: 3
|
Posted: Fri 23 Jul '10 11:04 Post subject: virtual host --> localhost overrides external IP |
|
|
Hello. First time posting .
I have a problem where I assign localhost as <VirtualHost *:8080> and a virtual domain in <VirtualHost **.*.**.***:80> where the asterisks are my IP. The problem is, I get forbidden 403 errors for my virtual domain but my localhost works.
NameVirtualHost *:8080
NameVirtualHost **.*.**.***:80
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog "C:/wamp/www/logs/error.log"
CustomLog "C:/wamp/www/logs/access.log" common
<Directory />
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost **.*.**.***:80>
ServerAdmin webmaster@drew
ServerName www.drew
DocumentRoot C:/SiteTesting/verifyemail
ErrorLog "C:/SiteTesting/verifyemail/logs/error.log"
CustomLog "C:/SiteTesting/verifyemail/logs/access.log" common
<Directory />
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I had it a bit different in configuration earlier when trying to debug but the best I had going was 'localhost' when I browsed was directing to my site (very strange, but the IP was being used on both.. so.. kind of has a link). If anyone can help or further info is needed I'd really appreciate it. Thanks.
The log file being used is not the log file directory of sitetesting but is going into the main apache logs as well. It is a forbidden 403 error 202.
Cheers again. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Fri 23 Jul '10 13:40 Post subject: |
|
|
You need to set the directory to the document root in each vhost
Code: |
...
DocumentRoot C:/wamp/www
...
<DirectoryC:/wamp/www>
...
|
You shouldn't have your log file inside the document root. |
|
Back to top |
|
RighTeouS84
Joined: 23 Jul 2010 Posts: 3
|
Posted: Fri 23 Jul '10 20:36 Post subject: |
|
|
NameVirtualHost *:80
NameVirtualHost **.*.**.***:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot C:/wamp/www
ErrorLog "C:/wamp/www/logs/error.log"
CustomLog "C:/wamp/www/logs/access.log" common
<Directory />
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost **.*.**.***:80>
ServerAdmin webmaster@drew
ServerName www.drew
DocumentRoot C:/SiteTesting/verifyemail
ErrorLog "C:/SiteTesting/verifyemail/logs/error.log"
CustomLog "C:/SiteTesting/verifyemail/logs/access.log" common
<Directory C:/SiteTesting/verifyemail>
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Still no joy. And the log file is also still not going into the right place.
Also, I think the only reason localhost is directing correctly is because its in the windows host file.
host file in drivers\etc looks like this:
127.0.0.1 localhost
::1 localhost
**.*.**.*** drew |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Fri 23 Jul '10 21:39 Post subject: |
|
|
Firstly,
NameVirtualHost *:80
the * indicates all IPs available, this means 127.0.0.1 and any other IP address on the computer (like 192.168.1.x). I am surprised you are not getting an error about the duplicated NameVirtualHost directive.
Secondly, what is the main host setup in httpd.conf, a duplicate of it must be the first vhost. THis is usually why problems arise when doing vhosts for the first time.
Thirdly, this is not good:
<Directory />
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
You are basically allowing Apache to give access to the entire C:\ this way.
<Directory "C:/wamp/www">
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
and
<Directory "C:/SiteTesting/verifyemail">
Options ALL
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
is a much more secure option. I realize you may be doing this trying to get it working, but I'm going to point it out anyway just in case.
Fourthly, what the heck does your error log say about the 403? Access denied by server configuration for where? C:/???? This may give clues to follow. |
|
Back to top |
|
RighTeouS84
Joined: 23 Jul 2010 Posts: 3
|
Posted: Sat 24 Jul '10 18:57 Post subject: |
|
|
Thanks glsmith
I'm self learning so if I get things wrong I apologise.
This is my httpd.conf file. I didn't know what you wanted exactly so I gave you a lot.
ServerName localhost:80
DocumentRoot "c:/wamp/www/"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "c:/wamp/www/">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
ErrorLog "c:/wamp/logs/apache_error.log"
CustomLog "c:/wamp/logs/access.log" common
And
Include conf/extra/httpd-vhosts.conf
Include "c:/wamp/alias/*" (this is for phpmyadmin which I use and is the only thing in there)
The output from my apache error log is :
[Sun Jul 25 00:47:19 2010] [warn] The Alias directive in C:/wamp/alias/phpmyadmin.conf.bak at line 1 will probably never match because it overlaps an earlier Alias.
[Sun Jul 25 00:47:19 2010] [warn] pid file C:/wamp/bin/apache/Apache2.2.11/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Jul 25 00:47:19 2010] [notice] Apache/2.2.11 (Win32) PHP/5.3.0 configured -- resuming normal operations
[Sun Jul 25 00:47:19 2010] [notice] Server built: Dec 10 2008 00:10:06
[Sun Jul 25 00:47:19 2010] [notice] Parent: Created child process 3372
[Sun Jul 25 00:47:20 2010] [warn] The Alias directive in C:/wamp/alias/phpmyadmin.conf.bak at line 1 will probably never match because it overlaps an earlier Alias.
[Sun Jul 25 00:47:20 2010] [warn] The Alias directive in C:/wamp/alias/phpmyadmin.conf.bak at line 1 will probably never match because it overlaps an earlier Alias.
[Sun Jul 25 00:47:20 2010] [notice] Child 3372: Child process is running
[Sun Jul 25 00:47:20 2010] [notice] Child 3372: Acquired the start mutex.
[Sun Jul 25 00:47:20 2010] [notice] Child 3372: Starting 64 worker threads.
[Sun Jul 25 00:47:20 2010] [notice] Child 3372: Starting thread to listen on port 80.
I didn't change anything and now i can connect via my external IP address but it is going to my localhost rather than my defined directory for my IP. I suppose thats because of what you already explained about *:80 being all IP addresses. I just want to be able to connect in from external sources to be able to update the email address in my mysql server.
The result i was getting before is not the same as I am getting now, it's like it is randomly deciding how it will act (i rebooted now though so that could have cleared some problems up). So I will go through your instructions and keep altering and see if anything helps. Otherwise I'll update this again. Thanks heaps |
|
Back to top |
|
|
|
|
|
|