Apache Dynamic Virtual Hosts - 403 Forbidden - apache

I am trying to configure the Apache server on my MacBooks (running Lion OS) to handle dynamic virtual hosts. I have managed to get it "working" but I whenever I access the domain I get a 403 Forbidden message. The hosts file is configured to point to 127.0.0.1 whenever one of these domains are requested. The httpd.conf is shown below:
VirtualDocumentRoot "/web"
<Directory "/web">
Options All
AllowOverride All
Order allow,deny
Allow from all
ScriptAlias /web/cgi-bin/
</Directory>
UseCanonicalName Off
VirtualDocumentRoot /web/%2/%1/public_html
This is set up so that http://foo.bar/ goes to "/web/bar/foo/public_html/".
I have checked the permissions on all the directories and files and they are all set to '777'. I have Googled for hours and hours and I am still getting 403 Forbidden. If there is anyone that can help me that would be greatly appreciated.
-Sam

You got it right, it's about permission. Check your site's parent folder permission, it might be stuck somehow on one of it's parent folder, make sure all of you site's parent folder from the root are readable by apache.

Related

apache xampp virtual host makes error 403 windows

I simply want to enable the test.php file to be accessible via a virtualhost so I added just 127.0.0.1 test.localhost in the windows host file and
<VirtualHost *:80>
DocumentRoot "D:/Programmordner/test"
ServerName test.localhost
<Directory "D:/Programmordner/test">
require all granted
#<FilesMatch "^((test|test2).testdateiendung1|.+.testdateiendung2)$">
<FilesMatch "^(test.php)$">
Allow from All
</FilesMatch>
in httpd-vhosts.conf
Now if I add the second, it seems I even cannot open the default documentation website by clicking the admin-button on the apache interface, which should not be affected? If I erase the second the alterations in the windows host file doesnt affect anything and I can access all files in standard htdocs. I switched different versions like allow from all, access denied access granted but nothing changed
If somebody knows there is already which solves my problem, I will not grudge him however I looked for it and it did not help
I made several fixes and changed to Port 80 (without httpS :( ) and everything is running now.

Accessing local host from another machine

I have seen many answers on this with what would appear to be simple solutions, none of which are working for me at this time.
I have WAMP install with Apache 2.4.33 32bit installed on a PC. I can access the site on that PC without a problem using the alias mySite.local.
The PC's host file looks like this
127.0.0.1 mySite.local
The remote lap top's host file is
192.168.1.114 mySite.local
That is the IP of the PC on the network.
httpd.conf
Listen 80
ServerName mySite.local:80
<Directory />
AllowOverride none
Require all denied
</Directory>
DocumentRoot "H:/Intranet/mySite_v2_www/public"
httpd-vhosts.conf
<VirtualHost *:80>
ServerName mySite.local
DocumentRoot "H:/Intranet/mySite_v2_www/public"
</VirtualHost>
I have tried disabling the windows firewall and virus checker on the PC.
The laptop appears to be getting there but being blocked. The message is..
Forbidden
You don't have permission to access / on this server.
Apache/2.4.33 (Win32) PHP/7.2.4 Server at mySite.local Port 80
So it looks like it can see Apache but is being blocked. So what else needs to be set to get access to the server?
Here are two of the links that I have been following to try and get this to work
Error message "Forbidden You don't have permission to access / on this server"
and
How do I connect to this localhost from another computer on the same network?
Thanks for any direction you can provide.
To complement the answer of Paul Neale:
Forbidden You don't have permission to access / on this server. Apache/2.4.33 (Win32) PHP/7.2.4 Server at mySite.local Port 80
That message is an answer from Apache. Disabling the windows firewall and virus checker on the PC won't have any effect, you are already reaching Apache there is not any networking problem.
Apache is receiving your request to access the root folder "public":
H:/Intranet/mySite_v2_www/public
But denies the request because, the directive Require local is enabled. This directive means, you can access to the content of public from the local server (localhost), which is the same to say 127.0.0.0 or localhost.
What you wanted is to tell apache that allows the access of certain IP address to the root directory "public".
When you changed the directive to Require all granted you are telling apache that, no matter who asks, give it access to / (root folder) in other words "public".
So, what you was searching for is "Access Control" in apache, and the directive Require can be used with IP address, here's the main document from Apache, this is an example:
Require host address
Require ip ip.address
It's important to differentiate between Network//Permissions problems. If you want to know if you are able to communicate (At network level) with Apache, you could do:
telnet <IP_APACHE_SERVER> <PORT_APACHE_SERVER>
#example: telnet 172.10.10.2 80
So after playing around will combinations for a day I found that in the httpd.conf I needed to change Require local to Require all granted in the section.
<Directory "H:/Intranet/mySite_v2_www/public/">
Options +Indexes +FollowSymLinks +Multiviews
AllowOverride all
# onlineoffline tag - don't remove
# Require local
Require all granted
</Directory>

Xampp keeps redirecting to dashboard

I am trying to set up local dev environment with virtual host, using XAMPP, on my new work laptop - running Windows 10.
I have exactly the same set up as on my Surface Pro where it works, but each time I try to access local, I get redirected to the dashboard.
In the hosts file I have added:
127.0.0.1 local.testing.co.uk
In httpd-vhosts.conf I have added:
<VirtualHost *:80>
DocumentRoot "C:/www/testing-co-uk/web"
ServerName local.testing.co.uk
<Directory />
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
In httpd.conf, I have amended the DocumentRoot and Directory as follows:
DocumentRoot "C:/www"
<Directory "C:/www">
My testing-co-uk folder is in C:/www
If I go to local.testing.co.uk, I get redirected to local.testing.co.uk/dashboard.
If I go to localhost, I also get redirected to local.testing.co.uk/dashboard.
If I go to localhost/index.php, I do get to the front page of site I want, however clicking on a link will take me to local.testing.co.uk/linkname (and a 404 error).
Can anyone kindly suggest what could be going wrong? I have been going slowly insane for about 10 hours now. I have checked various other posts within Stack Overflow and tried various solutions, and of course, restarted Xampp every time.
Any help would be really appreciated.
Kind regards
James

How do I access the parent directory of public_html in Apache?

I remember reading a while ago how it's possible for someone to access your computers filesystem from the website. I want to know how to do it, so I can test and prevent it from happening.
Running Apache 2.4 on Windows via XAMPP
My virtualhost is set up like so:
<VirtualHost *:80>
ServerName local.scrap
DocumentRoot "D:/Dropbox/www/scrap/public_html/"
<Directory "D:/Dropbox/www/scrap/">
Order allow,deny
Allow from all
Require all granted
</Directory>
ErrorLog "D:/Dropbox/www/scrap/logs/error.log"
</VirtualHost>
There is an index2.html in scrap/ and index.html in scrap/public_html/
hosts is set up to be 127.0.0.1 local.scrap
If I type the URL http://local.scrap/ I get index.html.
If I type the URL http://local.scrap/../index2.html it gets redirected to http://local.scrap/index2.html
Why is the ../ URL getting redirected to the DocumentRoot path?
Often times a non-malicious user-agent will resolve ../ in the URL before it ever contacts the server. But even without that, webservers are designe to not allow that kind of directory traversal outside of context roots.
You'd need to test with telnet/netcat/s_client to be sure.
If there's a directory traversal or LFI vulnerability in the website application code then this might indeed be possible.
Also, some webservers have directory traversal vulnerabilities. However, the current version of Apache has no known weaknesses in this respect.

Allowing 0.0.0.0 access in WAMP

Everything is setup correctly, but I'm getting "403..... Forbidden You don't have permission to access / on this server." error's when I access my IP address or my TLD. Any help?
In your VirtualHost, make sure that you have access permissions set in the Directory block...
order allow,deny
allow from all
Check your DocumentRoot folder for an .htaccess file, it can override the above.
Aside from that, you can also get this error when your VirtualHost does not contain the proper ServerName or ServerAlias and the request ends up falling into the default httpd.conf setup.
Also consider trying out another WAMP package.
xampp (free) -
WampDeveloper Pro (commercial) -
WampServer (free)
You are probably making requests from ::1, which is IP6 127.0.0.1.
So just update your <Directory "c:/wamp/www/"> section at C:\wamp\bin\apache\ApacheX.X.X\conf\httpd.conf sections to:
Order Deny, Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Remember to also do it in all conf files of C:\wamp\alias
This way you preserve the apache security.