WAMP & Vhosts. Access from internet = 403 Forbidden - apache

WAMP 32 running on Windows 10 machine, with Apache server (2.4) set "Online". Acces from other LAN computers is possible, however when attempting to access the server from the Internet (using public IP number), an error 403/forbidden is issued.
Happens with the following configuration (vhosts):
NameVirtualHost *
<VirtualHost *>
DocumentRoot "E:\Users\Rix\Offline Drive\wordpress"
ServerName localhost
<Directory "E:\Users\Rix\Offline Drive\wordpress">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *>
DocumentRoot "E:\Users\Rix\Offline Drive\WebG\Wordpress"
ServerName ghiandalocal
<Directory "E:\Users\Rix\Offline Drive\WebG\Wordpress">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
BTW, in vhosts there are 2 servers available, how can I access a specific one using a public IP?

About the 403 error you should add : Require all granted for your directories.
About the 2 servers availables, you can add for example another port like :
Listen 80
Listen 81
<VirtualHost *:80>
DocumentRoot "E:\Users\Rix\Google Drive\Documents\Biz\Progetti\wordpress"
ServerName localhost
<Directory "E:\Users\Rix\Google Drive\Documents\Biz\Progetti\wordpress">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:81>
DocumentRoot "E:\Users\Rix\Offline Drive\Web Ghianda\Wordpress"
ServerName ghiandalocal
<Directory "E:\Users\Rix\Offline Drive\Web Ghianda\Wordpress">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Hope it helps you

Related

Why does port-based VirtualHost not work?

I'm trying to serve up two different Django apps on two separate ports. I have app1 on port 80 and app2 on port 8080. So what I'm expecting is that when I put example.com:80 into my browser, my request should get served up from app1, and when I put example.com:8080 into my browser, my request should get served up from app2. However, sometimes it will serve up my request from the wrong app. Then, after a few refreshes, it will sometimes switch. What's more, sometimes it will serve up from the correct app and then, after a few refreshes, switch to the wrong one. I know this isn't due to caching on the browser's end because I've also tried sending requests with curl from the machine and I get the same behavior. I can't understand why I'm getting this unexpected, nondeterministic behavior.
Here is my VirtualHost configuration:
<VirtualHost *:80>
ServerAlias *
ServerPath /app1/
WSGIScriptAlias /app1 /home/eyuelt/app1/app1/wsgi.py
Alias /app1/static /home/eyuelt/app1/staticfiles
<Directory /home/eyuelt/app1/app1>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app1/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Listen 8080
<VirtualHost *:8080>
ServerAlias *
ServerPath /app2/
WSGIScriptAlias /app2 /home/eyuelt/app2/app2/wsgi.py
Alias /app2/static /home/eyuelt/app2/staticfiles
<Directory /home/eyuelt/app2/app2>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app2/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
I suspect this might be the problem:
http://httpd.apache.org/docs/2.2/vhosts/examples.html
This is what you want: You have multiple domains going to the same IP
and also want to serve multiple ports. By defining the ports in the
"NameVirtualHost" tag, you can allow this to work.
One or both of these could be the problem: If you try using
without the NameVirtualHost name:port or you
try to use the Listen directive, your configuration will not work.
Server example:
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot /www/domain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot /www/domain-8080
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot /www/otherdomain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>

dns points to wrong directory

I'm trying to setup two virtual hosts in windows using xampp. From what I've read one have to alter the windows hosts file and xampp's httpd-vhosts.conf file.
hosts file:
127.0.0.1 gholizadeh
127.0.0.1 doostr
127.0.0.1 localhost
vhosts file:
NameVirtualHost *:80
<VirtualHost gholizadeh>
DocumentRoot "E:\xampp\htdocs\lowkey\pappa"
ServerName gholizadeh.se
ServerAlias www.gholizadeh.se
<Directory "E:\xampp\htdocs\lowkey\pappa">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost doostr>
DocumentRoot "E:\xampp\htdocs\lowkey"
ServerName doostr.com
ServerAlias www.doostr.com
<Directory "E:\xampp\htdocs\lowkey">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost localhost>
DocumentRoot "E:\xampp"
ServerName localhost
<Directory "E:\xampp">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
But I'm having problem accessing these files. When I try it from my own LAN I get prompted to the xampp site and when get access denied when trying to enter it from extern network. What am I doing wrong?
You got the VirtualHost command wrong. Use it like this instead:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName gholizadeh.se
ServerAlias www.gholizadeh.se
DocumentRoot "E:\xampp\htdocs\lowkey\pappa"
<Directory "E:\xampp\htdocs\lowkey\pappa">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName doostr.com
ServerAlias www.doostr.com
DocumentRoot "E:\xampp\htdocs\lowkey"
<Directory "E:\xampp\htdocs\lowkey">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "E:\xampp"
<Directory "E:\xampp">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Some more things:
* you should add a ServerAdminto each host
* the entries in the host file are just for internal debugging purposes, I assume?
And a side remark:
you don't plan to serve real web pages in the internet from this MS-Windows system, do you?

XAMPP Windows Apache VirtualHost 403 Forbidden

I had XAMPP running fine with virtual hosts on my winodws 8 machine until I was forced to restart my computer (windows update). After restarting I've noticed my virtual hosts weren't working any more. Instead of trouble shooting too much I decided to reinstall XAMPP (currently have XAMPP 3.1.0 running. Which is runnign Apache v 2.4.3)
I have my windows host file edited to redirect sitename.localhost to 127.0.0.1 and this is what I have in my httpd-vhost.conf:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Users\USER\Documents\sitename"
ServerName sitename.localhost
<Directory "C:\Users\USER\Documents\sitename">
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
Every time I try to access http://sitename.localhost I get a 403 Access Forbidden error. Any idea what I'm doing wrong?
Try adding Require all granted to the Directory configuration:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Users\USER\Documents\sitename"
ServerName sitename.localhost
<Directory "C:\Users\USER\Documents\sitename">
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Also, try to set reading permissions to the web site folder for Authenticated users.
This will list out as index.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Users\USER\Documents\sitename"
ServerName projectname.dev
ServerAlias projectname.dev
<Directory "C:\Users\USER\Documents\sitename">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
could you test this code pls instead of yours?
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Users\USER\Documents\sitename"
ServerName sitename.localhost
<Directory "C:\Users\USER\Documents\sitename">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
btw, do you have index.html/php file in folder "C:\Users\USER\Documents\sitename", don't you?

Configuring Apache vhost: sites having inner sites. possible?

i am wondering if i am doing some thing wrong
i have http://localhost pointing to the directory D:\Projects\Websites
then i want to create a inner site http://learningzf in D:\Projects\Websites\php\ZendFramework\LearningZF\public. this is so that i can use URL's like /users/login instead of specifying the full url
i find that if i add the entry in vhosts to point http://learningzf to D:\Projects\Websites\php\ZendFramework\LearningZF\public, localhost will also point to D:\Projects\Websites\php\ZendFramework\LearningZF\public
<VirtualHost *:80>
DocumentRoot "D:/Projects/Websites/php/ZendFramework/LearningZF/public"
ServerName localhost
</VirtualHost>
<Directory "D:/Projects/Websites/php/ZendFramework/LearningZF/public">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
DocumentRoot "D:/Projects/Websites"
ServerName localhost
</VirtualHost>
<Directory "D:/Projects/Websites">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
i noticed if i move the entries for learningzf below localhost, both learningzf &localhost will point to D:/Projects/Websites
UPDATE
following #KikoV answer, i have modified it to make it work ...
NameVirtualHost 127.0.0.1:80
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "D:/Projects/Websites"
<Directory "D:/Projects/Websites">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
</VirtualHost>
<VirtualHost learningzf:80>
ServerName learningzf
DocumentRoot "D:/Projects/Websites/php/ZendFramework/LearningZF/public"
<Directory "D:/Projects/Websites/php/ZendFramework/LearningZF/public">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
</VirtualHost>
You should use NameVirtualHost directive.
If host "learningzf" is pointing to localhost, (127.0.0.1), you could use:
Note: In _default _ , last underscore should go togheter.
NameVirtualHost 127.0.0.1:80
<VirtualHost _default _:80>
ServerName localhost
<Directory "D:/Projects/Websites">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
</VirtualHost>
<VirtualHost learningzf:80>
ServerName learningzf
<Directory D:/Projects/Websites/php/ZendFramework/LearningZF/public">
AllowOverride All
Options All
Order allow,deny
Allow from 127.0.0.1
</Directory>
</VirtualHost>
This way you could access to http://localhost and http://learningzf and Apache will know which should use.
(By default, it will go to D:/Projects/Websites).
Note2: remember to add "127.0.0.1 learningzf" line to c:/windows/system32/drivers/etc/hosts file in order to get hostname resolved.

How to set up virtual hosts on Apache 2.2

Can anyone direct me to a good tutorial on how to set up virtual hosts using Apache 2.2? Here's my situation:
I have Apache running on my laptop and I want two websites-- one on port 80 and one on port 8089. I want to access each site from the other computer on my network by entering the computer's IP address, such as http://192.168.1.102 and http://192.168.1.102:8089. Yet when I enter the second url, it directs me to the website running on port 80.
Thanks in advance for any help.
First you need to instruct Apache to listen on the ports you need:
Listen 80
Listen 8089
Second you need to tell it what to do with 80 and 8089 traffic:
<VirtualHost *:80>
DocumentRoot /website/site80
ServerName internet.dev
</VirtualHost>
<VirtualHost *:8089>
DocumentRoot /website/site8089
</VirtualHost>
Third you need to "allow" Apache to use those directories:
<Directory "C:/website/site80">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "C:/website/site8089">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Just have 2 virtual hosts defined like this, but with differeing DocumentRoots:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.somecompany.com
DocumentRoot "/docs/dummy-host.somecompany.com"
ServerName dummy-host.somecompany.com
ServerAlias www.dummy-host.somecompany.com
ErrorLog "logs/dummy-host.somecompany.com-error.log"
CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>
<VirtualHost *:8089>
ServerAdmin webmaster#dummy-host.somecompany.com
DocumentRoot "/docs/dummy-host.somecompany.com"
ServerName dummy-host.somecompany.com
ServerAlias www.dummy-host.somecompany.com
ErrorLog "logs/dummy-host.somecompany.com-error.log"
CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>