Forbidden!
Posted by: linuxman74 (---.43-85-b.business.telecomitalia.it)
Date: May 18, 2016 03:43PM

Hi, my name is Davide. Nice to meet you.
I have a problem with Apache 2.5 in WAMP Server 3.0.4. I have granted access to the server pages only from the same server. If I try from another host in the lan I have everytime a Forbidden message.
I have modified the http.conf e his Allow directives but it not work.
This is my httpd.conf

(Tnx and i'm sorry for my bad english)


ServerSignature On

ServerTokens Full

ServerRoot "E:/wamp64/bin/apache/apache2.4.18"

Define APACHE24 Apache2.4

Listen 0.0.0.0:80
Listen [::0]:80

LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule php5_module "E:/wamp64/bin/php/php5.6.19/php5apache2_4.dll"

<IfModule unixd_module>
User daemon
Group daemon
</IfModule>


ServerAdmin test@test.com

ServerName pc-test:80

<Directory />
Allow from all
</Directory>

HostnameLookups Off

DocumentRoot "E:/wamp64/www"
<Directory "E:/wamp64/www/">
Options +Indexes +FollowSymLinks
Allow from all
Require all granted
</Directory>

<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>

<Files ".ht*">
Require all granted
</Files>

ErrorLog "E:/wamp64/logs/apache_error.log"

LogLevel warn

<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "E:/wamp64/logs/access.log" common
</IfModule>

<IfModule alias_module>
ScriptAlias /cgi-bin/ "E:/wamp64/cgi-bin/"
</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "E:/wamp64/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>

<IfModule mime_module>
TypesConfig conf/mime.types
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
</IfModule>

EnableSendfile off

AcceptFilter http none
AcceptFilter https none

Include conf/extra/httpd-autoindex.conf
Include conf/extra/httpd-vhosts.conf

<IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include "E:/wamp64/alias/*"

Options: ReplyQuote
Re: Forbidden!
Posted by: Otomatic (Moderator)
Date: May 18, 2016 03:57PM

Hi,

Do not modify httpd.conf, especially to put full of errors.
Replace the file as it was after installation and create VirtualHost: The need for Virtual Host
And you authorize the VirtualHost to be accessed from the network.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Forbidden!
Posted by: RiggsFolly (Moderator)
Date: May 18, 2016 04:08PM

First you are mixing Apache 2.2 syntax with Apache 2.4 syntax i.e.

Apache 2.2 = `Allow form all`
Apache 2.4 = `Require all granted`

This just gets Apache 2.4 very confused, dont do it!


Second return this section to its original state

<Directory />
Allow from all
</Directory>

To

<Directory />
    AllowOverride none
    Require all denied
</Directory>

This is the initial setting and sets the whole drive that Apache is installed on to be NOT ALLOWED to be accessed by Apache. If you got hacked, this would stop a hacker gaining access to your whole drive.
Standard practice with Apache is to DENY access to everything and then GRANT access to ONLY THOSE THINGS IT NEEDS ACCESS TO


Third:
Change this
<Directory "E:/wamp64/www/">
Options +Indexes +FollowSymLinks
Allow from all
Require all granted
</Directory>

back to the original

<Directory "E:/wamp64/www/">
    Options Indexes FollowSymLinks
    AllowOverride all

#   onlineoffline tag - don't remove
    Require local
</Directory>



Now to allow access to your localhost (which is not a good idea by the way) from anywhere on your local lan

Edit \wamp\bin\apache\apache2.4.18\conf\extra\httpd-vhost.conf

Where you will find this

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot D:/wamp/www
	<Directory  "D:/wamp/www/">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>

and change it to

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot D:/wamp/www
	<Directory  "D:/wamp/www/">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Require local
                Require ip 192.168.1         # <- New line
	</Directory>
</VirtualHost>


Note the use of only the first 3 quartiles of the ip address indicating to Apache, that any ip address starting with 192.168.1 is allowed access.




PS: It is a much better idea to leave this localhost set as it was originally and to create a SUBFOLDER under \wamp\www\ like \wamp\www\project1

And then create a new Virtual Host in `\wamp\bin\apache\apache2.4.18\conf\extra\httpd-vhost.conf` like this

<VirtualHost *:80>
	ServerName localhost
	DocumentRoot D:/wamp/www
	<Directory  "D:/wamp/www/">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Require local
	</Directory>
</VirtualHost>

<VirtualHost *:80>
	ServerName project1
	DocumentRoot D:/wamp/www/project1
	<Directory  "D:/wamp/www/project1">
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Require local
                Require ip 192.168.1
	</Directory>
</VirtualHost>

Now localhost cannot be accessed from any other PC but your project(s) can.

See this post for more help on setting up Virtual Hosts [forum.wampserver.com]

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Forbidden!
Posted by: linuxman74 (---.43-85-b.business.telecomitalia.it)
Date: May 18, 2016 04:20PM

Tnx a lot.
Now It Work fine!

Options: ReplyQuote


Sorry, only registered users may post in this forum.