trying to enable mod_status but I get "Syntax error..." - apache

I am trying to enable mod_status on my server. I have mod_status.so module installed and the relevant part of my .conf file is (I plan to restrict access to only my IP once I get it running):
LoadModule status_module modules/mod_status.so
<Location /server-status>
SetHandler server-status
Order Allow,Deny
Allow from all
</Location>
I restart apache and get an error: "Syntax error on line 4 of /path/to/httpd.conf"...which points to the line:
Order Allow,Deny
I've tried all combinations of lowercase, uppercase and a space between the comma and "Deny". What am I doing wrong?
I am using Apache 2.2.25 (and I do have 2 virtualhosts)
Thanks!

Related

Apache AH00526 Syntax Error

I am trying to start my Apache server and keep receiving this error:
AH00526: Syntax error on line 261 of C:/Apache24/conf/httpd.conf:
Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration.
With some research I found a suggestion of enabling the LoadModule authz_host_module but that did not correct the issue.
The code where the error is:
260 <Files ~ "^\.ht">
261 Order allow,deny
262 Deny from all
263 Satisfy All
264 </Files>
Any suggestions on how to fix this problem?
In Apache 2.4 you don't use 2.2 directives.
Remove all "Order/Deny/Allow/Satisfy" directives and just use:
Require
Following your example:
<Files ~ "^\.ht">
Require all denied
</Files>
Please see upgrading for further changes regarding 2.4 version.

Apache httpd server-info and server-status

I am on Windows 7, using Apache 2.2.29.
I modified my httpd.conf file to load moduels for mod-info.so and mod-status.so
and in my extra/httpd-info.conf, I updated server-status and server-info Location stancas to allow from
So, in my httpd.conf, I uncommented these:
LoadModule info_module modules/mod_info.so
LoadModule status_module modules/mod_status.so
and in my extra/httpd-info.conf, I modified as below to add my ip-address in "Allow from":
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from my-ip-address:no-port#
</Location>
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from my-ip-address-no-port
</Location>
If I just enter my-ip-address:my-port in browser, I get
"It Works!"
However, when I try to get info and status of my server, I get
for server-info:
Not Found
The requested URL /server-info was not found on this server.
for server-status:
Forbidden
You don't have permission to access /server-status on this server.
I am new to Apache, please provide explanation.
Much appreciated,
On modern windows, If you edit httpd.conf from your normal user account you can end up creating a 2nd copy specific to your userid that the server doesn't see. Make sure to edit it as Administrator.

httpd.conf and Location Match error

This is how part of my httpd.conf file looks
(apache 2.215, mod_perl 2.0000005-orsomething, newest HTML::Mason)
# user's Mason Handler Thingy Handler
SetEnv PERL5 /home/user/perl5/lib
PerlSwitches -I/home/user/perl5/lib
PerlModule HTML::Mason::ApacheHandler
<Directory /var/www/html/user>
<LocationMatch "\.html$">
SetHandler modperl
PerlResponseHandler HTML::Mason::ApacheHandler
</LocationMatch>
</Directory>
# end user's Mason Handler Thingy Handler
The error I get on restarting apache back up is:
[root#server folder]# /etc/init.d/httpd start
Starting httpd: Syntax error on line 1020 of /etc/httpd/conf/httpd.conf:
<LocationMatch not allowed here
[FAILED]
[root#server folder]#
Line 1020 is the location match tag
I don't exactly know what's wrong with this configuration, I can't get apache to restart back up.
The error is telling you that you can't nest LocationMatch in Directory. You probably want FilesMatch.

Apache - how to get REMOTE_USER variable

Previously I used the IIS server as PHP server. Currently, it is the apache.
On IIS I could access to the variable $_SERVER ['REMOTE_USER'] which returns the username and domain (eg domain\user) but after installing XAMPP this variable is not available.
What I should do to get this variable get again?
My app is on local network with no-internet connection
Finally got it to works! :D
Download the module from here https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)
Copy the mod_authnz_sspi.so from Apache24\modules folder and place it in the modules folder of your Apache folder on your webserver
Under the httpd.conf file (Config file for your apache) place this line of code. Try to load this as the last module:
LoadModule authnz_sspi_module modules/mod_authnz_sspi.so
Make sure that the following modules are uncommented
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so
PS: both the above modules are required for this to work.
Place the following code in your httpd.conf file
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
Restart your apache servive and hopefully it should restart without any issues.
Now in order to recognise the user , use the following code on a php page
echo $_SERVER['PHP_AUTH_USER'];
That's all.
I'm using:
XAMPP Control Panel 3.2.1
APACHE 2.4
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
If you use ModRewrite or other I suggest you to keep
Options Indexes FollowSymLinks Includes ExecCGI
otherwise you'll get an error like
[rewrite:error]: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions
You can only access the remote user if Apache has actually authenticated the user, check the apache auth howto.
I battled with this for a long time, it turned out that I had to install VC redistributable to make it work.

How to enable mod_info in Apache?

I've gone through the Apache guide to enable to mod_info.
As per doc:
To configure mod_info, add the following to your httpd.conf file.
<Location /server-info>
SetHandler server-info
</Location>
You may wish to use mod_access inside the <Location> directive to limit access to your server configuration information:
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from yourcompany.com
</Location>
Once configured, the server information is obtained by accessing
http://your.host.dom/server-info
In my case this link is not giving any info. Is there anything I need to install as mod_info.c or something? Is there anything I need to put as AddModule or something?
There should be a mod_info.so that must be on a path Apache 2 can find. For example, I have:
kdp#darwin ccl $ locate mod_info.so
/usr/lib64/apache2/modules/mod_info.so
Then, I have these in my httpd.conf:
ServerRoot "/usr/lib64/apache2"
LoadModule info_module modules/mod_info.so
This is made available by a snippet in /etc/apache2/modules.d/00_mod_info.conf:
<IfDefine INFO>
# Allow remote server configuration reports, with the URL of
# http://servername/server-info
<Location /server-info>
SetHandler server-info
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
</IfDefine>
(The IfDefine is only needed because of the way stuff is set up on Gentoo.)
Check if info_module is loaded.
% /usr/local/sbin/httpd -t -D DUMP_MODULES | grep info_module
If it is not loaded, add following line to httpd.conf. Note that path/to must be replaced with appropriate path.
LoadModule info_module path/to/mod_info.so
I got the solution.
When I check ./apachectl -l, mod_info has not been installed.
To install the Mod_info or any module, First Compile and install Apache by ./configure --enable-info make make install
More info for install module : http://publib.boulder.ibm.com/httpserv/manual60/install.html
Check ./apachectl -l, mod_info would be there in the list
Enable server-info by updating httpd.conf
invoke url http://your.host.dom/server-info
One thing I am not sure why apache mod_info not installed default installation.