I am having a strange problem which I have never had before. I have freshly installed Linux (it's a little-known linux release based on Ubuntu, used in a narrow industry segment, I hope it itself doesn't matter much). I have Apache installed. Every time I am trying to open
http://localhost
(locally) I get 401 Authorization required response.
My /etc/apache2/sites-enabled/000-default is:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
The /var/www directory doesn't contain any .htaccess files. The /etc/apache2/apache2.conf configuration file doesn't contain anything containg text "auth".
File permissions for /var/www is: drwxrwxrwx, root:www (owner user - root, group www). The apache user "www-data" is a member of the group "www". The index file /var/www/index.html has the same permissions.
Content of /etc/apache2/mods-enabled/ is the following:
alias.conf authz_user.load dir.load php5.load
alias.load autoindex.conf env.load setenvif.conf
auth_basic.load autoindex.load mime.conf setenvif.load
authn_file.load cgi.load mime.load status.conf
authz_default.load deflate.conf negotiation.conf status.load
authz_groupfile.load deflate.load negotiation.load
authz_host.load dir.conf php5.conf
Built-in modules (/usr/sbin/apache2 -l):
core.c
mod_authn_pam.c
mod_auth_basic.c
mod_log_config.c
mod_logio.c
prefork.c
http_core.c
mod_so.c
The interestign thing is that if I add the following line:
Satisfy Any
to the <Directory /> section in /etc/apache2/sites-enabled/000-default file, every request generates the following error in Apache's error log:
[Mon Oct 01 12:34:59 2012] [notice] child pid 4445 exit signal Segmentation fault (11)
and Apache returns nothing, just closes the connection.
I am completely lost, what makes Apache to ask for authorization, and even don't know how to debug it. Enabling debug level for the log files doesn't reveal anythin both in access.log and error.log. Any help or direction what to look at will be appreciated. Thanks.
Finally I contacted with this Linux vendors and it turned out that this particular Linux release is built in the way, that Apache authorization just can't be turned off, so there is no any way to switch it off except removing apache packages and replace them with other ones.
Related
I got a Raspberry Pi yesterday and have mounted an additional hard drive on it. I'm planning to use it on a web server. However, I wish to host my files on the hard drive, not the small SD card where the OS is located.
I installed Apache and created a Virtual Host config file, specifying the DocumentRoot and the directory on the external HDD where the website is located. However, it gives a 403 error. The system log gives the following information:
Permission denied: [client 123.456.789.1250527] AH00035: access to / denied (filesystem path '/media/myusername/myHDD') because search permissions are missing on a component of the path
I've tried a number of different things: setting the DocumentRoot to /var/www/html but specifying the path to the HDD in the Directory tag, changing the DocumentRoot in the default site to the path to the HDD's directory that I want to serve, adding the line DocumentRoot "/media/myusername/myHDD" in the apache2.conf file. I changed the ownership of the /myHDD folder to the www-data user. I eventually deleted the /var/www/html folder and created a symlink to the HDD's directory with the name html, but that causeed this error:
AH00037: Symbolic link not allowed or link target not accessible: /var/www/html
What do I need to do to make Apache serve these websites that are on the HDD and not the system SD (only 16GB)? Here is my VirtualHost config:
<VirtualHost *:80>
ServerAdmin me#myemail.com
ServerName myurl.com
ServerAlias www.myurl.com
DocumentRoot "/var/www/html"
Alias "/webals" "/media/userName/MyHardDrive/public_html/myurl.com/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/media/userName/MyHardDrive/public_html/myurl.com">
Require all granted
Order allow,deny
Allow from all
</Directory>
I'm not sure what is going on here. Haven't really used Apache much in the past - have preferred nginx.
Any help here would be good.
I created a virtual host and tried to forbid access to it by using the directory directive with Require all denied.
<VirtualHost *:80>
DocumentRoot /var/www/test
<Directory /var/www/test/>
Require all denied
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
However, the users have still access to every page. How can i solve this?
These directives won't do anything if they're in a VirtualHost not matched by the current request.
Your VirtualHost has no ServerName nor ServerAlias, which is the primary means of having a VirtualHost used for a request.
If you think configuration is being ignored, step is to verify that this VirtualHost is in use. One simply way is to define a unique logfile for the virtual host. Yours does not look unique.
apachectl -S will quickly summarize your virtual hosts.
The Require must not be combined with the deprecated Order, Allow, Deny directives (since Apache 2.4).
Review all the configuration files and replace Order/Allow/Deny with Require, possibly combined using RequireAll, RequireAny, RequireNone.
Note that the configuration is not necesarrily located in the single file holding <VirtualHost>. You need to review all the server configuration files.
E.g. on Ubuntu this includes:
all files in /etc/apache2/sites-enabled
all files in /etc/apache2/conf-enabled
depending on AllowOverride setting you may need to review all the .htaccess files for any directories reachable from the web
I want to prevent direct access to the server web root showing the Ubuntu home page at /var/www/html/index.html
I have changed the following:
/etc/apache2/sites-available/000-default.conf
DocumentRoot /var/www/websites
And restarted Apache but it's still going to /var/www/html if I visit my server directly.
Edit:
It appears this problem is only when I access the server on HTTPS. On HTTP it works fine.
You also need to change in /etc/apache2/apache2.conf. Find this:
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change to your desired directory
I have a Linux box running Centos 6.6 with Apaches 2.2.x
For some unknown reason, turning on the rewrite engine causes a 403 error (this happens whether I add a rewrite rule or not).
I have spent hours researching this and have made changes to my config in accordance with advice I have found in many places, but still got nowhere.
Currently in my .htaccess I have this:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
</IfModule>
In the directives for the virtual host, I have this:
DocumentRoot /var/www/html/example.uk
<Directory /var/www/html/example.uk>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ServerName example.uk
ServerAlias www.example.uk
(This seems to work in a Debian box, but not for my Centos machine.)
In my httpd.conf I have changed
AllowOverride None
to
AllowOverride All
my httpd.conf also contains
LoadModule rewrite_module modules/mod_rewrite.so
Error log says:
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /var/www/html/example.uk
Now, I have previously added SymLinksIfOwnerMatch to the directives, but it didn't solve the problem.
I followed this and all seemed to go as it should.
This happens when Apache doesn't have execute rights for
/var
/var/www
/var/www/html
/var/www/html/example.uk
Run:
chmod o+x /var /var/www /var/www/html /var/www/html/example.uk
Since apache version >= 2.4 directive
Order allow,deny
allow from all
leads to a global 403, to ensure this if you check you're apache's log :
[Tue May 05 11:54:32.471679 2015] [authz_core:error] [pid 9497] [client 127.0.0.1:35908] AH01630: client denied by server configuration: /path/to/web/
Comment Directive Order and add Require all granted like bellow:
Require all granted
#Order allow,deny
#allow from all
Hope this help.
Edit :
explanation from apache
This behaviour is provided by new module mod_authz_host
For list of restriction available (ip, host, etc) http://httpd.apache.org/docs/2.4/en/mod/mod_authz_host.html
You should remove this line from htaccess
Options +FollowSymLinks
You already have it in the apache vhost file. Also if you should add a rule if you're going to turn on mod_rewrite or there is no point to turning it on.
Another possibility with Apache 2.4 is caused by Options -FollowSymlinks which will also throw a 403 error and generate the following log:
AH00670: Options FollowSymLinks and SymLinksIfOwnerMatch are both off,
so the RewriteRule directive is also forbidden due to its similar
ability to circumvent directory restrictions
This was not the case in the original post, but if it comes up you would need to re-enable FollowSymLinks using this line:
Options +FollowSymLinks
This is the opposite problem from most about which I have read. I am running Ubuntu 8.04 on an Amazon instance with Apache 2.2.8 and I can't figure out why setting AllowOverride to None for root doesn't stop my .htaccess file from being included.
I have a sub-directory with hello.py in it and an .htaccess file. When I browse to the file, it works fine with modpython serving the file. If I put some garbage in .htaccess I get a server error, so I know the .htaccess file is being used. Also if I delete the .htaccess file, hello.py is no longer server by modpython - instead the browser tries to open it.
In one of my sites-available (linked in sites-enabled), I have "AllowOverride None" for the root directory. I thought that this would prevent .htaccess from being included from root and all its sub-directories which should cause hello.py to not be served by mod_python. However, it continues to be served fine and I can test that .htaccess is still being included because when I modify it, I see the results in my browser.
Maybe there is something I am not understanding about my file in sites-enabled. This is the file I am using:
NameVirtualHost *:8080
<VirtualHost *:8080>
<Directory />
AllowOverride None
</Directory>
</VirtualHost>
Thanks for any help.
The reason the file is not served via mod_python when you delete .htaccess is because the setup for mod_python is located in it. If you move that stuff to your sites-available file, you can delete .htaccess, turn a blind eye to the problem, and call it a day.
If that doesn't satisfy you, then as to why .htacess is being read at all, I can't say. You are correct that AllowOverride None should prevent the file from ever being read. Have you considered the possibility that you screwed something up when adding the virtual site? Try throwing some garbage into the config and see if it complains, just to be sure it's being read at all.
AllowOverride is only allowed in <Directory>-sections, so you've done everything right.
One problem you could have is that other (sub-)<Directory>-sections set AllowOverride to something different than None. That will override the setting for these subdirectories.
I use
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
</Directory>
and in /var/www (my docroot) I can use .htaccesses.
The reason why mod_python does not work anymore if you delete your .htaccess is that mod_python setup is usually in .htaccess files.
If you need more information, please send us your configuration.
PS: In fact the docuementation linked above says that you should never set AllowOverride to something not None in <Directory />.