FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


httpd.conf (Virtual Hosts Problem) Please help





imagefree
I am trying to host multiple domains (or subdomains) on my pc. 1 domain is working file if i use the following:

Code:
ServerAdmin postmaster@localhost
ServerName toit.uni.cc:80
DocumentRoot "D:/websites/toit.uni.cc/www-main"


but when i use VirtualHost containers
Code:
<VirtualHost toit.uni.cc>
  ServerName toit.uni.cc
  DocumentRoot "D:/websites/toit.uni.cc/www-main"
</VirtualHost>

<VirtualHost toit1.uni.cc>
  ServerName toit1.uni.cc
  DocumentRoot "D:/websites/toit1.uni.cc/www-main"
</VirtualHost>


both work locally, by do not work from outside of my network. It shows 403 Forbidden page.

Can you please tell me what and where the problem may be?
AftershockVibe
Ensure that the directory (or index.html / index.php or similar, if it exists) in D:/websites/toit1.uni.c/www-main has read permissions for both user, group and other.

Test that. You might not even need "other". Quickest way to do this is with chmod 644.
imagefree
AftershockVibe wrote:
Ensure that the directory (or index.html / index.php or similar, if it exists) in D:/websites/toit1.uni.c/www-main has read permissions for both user, group and other.

Test that. You might not even need "other". Quickest way to do this is with chmod 644.


i can access it on my browser using http://toit.uni.cc/, but when i use proxy to access it remotely, it shows 403 error. Apache log shows that a request was received and 403 response was given.

Also the problem occures when i use multiple virtualhosts. Even the hose (toit.uni.cc) stops working through proxy when i use multiple vistual hosts. Everything works fine in both cases when i access any site locally. So i dont think there is some permission related problem. Problem is in virtualhost setting.

I googled a lot about the broblem and i applied all th information i got in result, but useless. So i posted here to get help from experienced frihosters like rvec etc.
cr3ativ3
Hey,

Your problem is interesting, at this point it seems like DNS is resolving fine for all parties involved, as you can connect fine at home. Your saying when you use a proxy it says 403 Forbidden, which points at the DNS resolving fine for outside hosts as well. (We assume hosts outside and your at home both are connecting to the same server in the end)

If we look at the difference between you at home, and hosts outside (like a proxy). The main difference in regards to connection, is the IP address. So my best guess given the information provided, is that your web server is for some reason configured to allow "you", if that is you on the same computer as your server, then it is allowing localhost to connect to it.

I'd say try one more thing, to see what is being blocked, if you have another computer at home... Try connecting, to your server from that computer. If it works from that computer, it sounds like your server is blocking any non-local IP addresses. If it gives that same 403 Forbidden error, that proxies were claiming, then your server is likely only allowing access from "localhost", (i.e. the computer it is running on).

Anyways, my best guess is to check the apache configuration and see if it is configured to block certain ip addresses, or configured to only allow certain addresses.

Your problem seems wierd in that, as you say remote hosts are getting a 403 Forbidden error, I would expect if the server was blocking certain people, like a firewall was causing the failure ... It would simply fail to connect, not respond with a 403 Forbidden.

Anyways, good luck. If you figure out what the problem was let us know! In case anyone else runs into a similiar problem.

As a side note, I wish we had a forum here for Servers/Networking, that way questions like this could be more properly directed, instead of a PHP/MySQL forum.
MM357
I guess the problem is now solved, as I can now see Ur site up,(unless U changed Ur DNS records) so if it is really fixed please tell us what u changed in the Apache configuration file.
imagefree
MM357 wrote:
I guess the problem is now solved, as I can now see Ur site up,(unless U changed Ur DNS records) so if it is really fixed please tell us what u changed in the Apache configuration file.


I did no change, i just removed all the virtualhost blocks.
As i told you earlier, the primary domain works, but if use more than 1 domain, all fail.

I am not blocking any IP. Also there are no IP related issues because there is no such thing in apache config file. if there are IP related issues, why 1 site that is setup by not using virtualhost blocks is accessible to proxies?
cr3ativ3
imagefree wrote:

but when i use VirtualHost containers
Code:
<VirtualHost toit.uni.cc>
  ServerName toit.uni.cc
  DocumentRoot "D:/websites/toit.uni.cc/www-main"
</VirtualHost>

<VirtualHost toit1.uni.cc>
  ServerName toit1.uni.cc
  DocumentRoot "D:/websites/toit1.uni.cc/www-main"
</VirtualHost>


If i'm not mistaken that syntax is in error, if you want to use Virtualhosts you will need to first somewhere in the apache configuration declare "NameVirtualHost *:80" and than each VirtualHost will need to be "<VirtualHost *:80>", apache goes into each virtualhost and looks for the ServerName directive and determines the site to display using that.


Code:

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName toit.uni.cc
  DocumentRoot "D:/websites/toit.uni.cc/www-main"
</VirtualHost>

<VirtualHost *:80>
  ServerName toit1.uni.cc
  DocumentRoot "D:/websites/toit1.uni.cc/www-main"
</VirtualHost>


This is how I have my server setup atleast and it works.

Best of luck Smile
imagefree
cr3ativ3 wrote:
Code:

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName toit.uni.cc
  DocumentRoot "D:/websites/toit.uni.cc/www-main"
</VirtualHost>

<VirtualHost *:80>
  ServerName toit1.uni.cc
  DocumentRoot "D:/websites/toit1.uni.cc/www-main"
</VirtualHost>


do i have to replace *s with host names?
Also please tell me How will server find that request is coming from toit.co.cc or toit1.co.cc in the above example ?

Also is :80 necessary at all places above?
cr3ativ3
imagefree wrote:

do i have to replace *s with host names?
Also please tell me How will server find that request is coming from toit.co.cc or toit1.co.cc in the above example ?

Also is :80 necessary at all places above?


It can tell by looking in each virtualhost and finding which Vhost has the ServerName toit.co.cc or toit1.co.cc. (Which does not seem the most logical, but it's how it works...)

The * is what I have in my files, so basically apply this virtualhost to all the IP Addresses apache is listening on, then the :80 tells it which port on those IP addresses, to apply the vhost for, so if you want a vhost that was to have SSL (HTTPS) ability you would use *:443.

Does that make sense?

If you have any questions, feel free to ask.
imagefree
So you mean my server will accept all requests coming to any IP address assigned to my server if I use * for a particular VirtualHost and then it will process whether the Server Name matches the HTTP HOST value?
cr3ativ3
imagefree wrote:
So you mean my server will accept all requests coming to any IP address assigned to my server if I use * for a particular VirtualHost and then it will process whether the Server Name matches the HTTP HOST value?


Correct, assuming in your httpd.conf or one of your configuration files above your vhosts a "Listen *:80", is declared.

Vhost for all ip's apache is listening on.

Code:

<VirtualHost *:80>
...
</VirtualHost>


Vhost for only one ip address, providing apache is already listening on this IP.

Code:

<VirtualHost 12.34.56.78:80>
</VirtualHost>


Obviously replaceing 12.34.56.78 with the ip you want it to apply too.

For your purposes the first one is probably more suitable and easier to understand/use.
imagefree
thanks creative for your help. I will ask here more questions later.
Related topics
simple php problem, please help...
an annoying problem - PLEASE help
Please help. I have a problem with installing FreeBSD
Problem with MySQL Server Please Help!!
Someone please help
A problem.. please help
Help please,"Forbidden You don't have permission to acc
Please help regarding editing of index file
encrypt and decrypt PROBLEM plss HELP!
Which is the source of the problem???PLEASE HELP ME!!!
Anyone please help me!
Internal Server Error in Joomla, Please help!
Need help with httpd.conf and .htaccess
Help! This small script has logical problems. Please help
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.