Hi guys,
I've been trying to solve this problem the whole day with no success.
I've been googling too, of course.
Basically, I want to force https-connection on my webserver, only on /nagios3 folder on my Apache running on Debian Lenny.
Everything is set up according the default, meaning that Nagios Apache config is placed in /etc/apache2/conf.d/nagios3.conf and it contains following:
Code:
ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
Alias /nagios3 /usr/share/nagios3/htdocs
<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3)>
Options FollowSymLinks
DirectoryIndex index.html
AllowOverride AuthConfig
Order Deny,Allow
Allow From 172.16.0.0/24 #the only thing I tweaked.
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios3/htpasswd.users
# nagios 1.x:
#AuthUserFile /etc/nagios/htpasswd.users
require valid-user
</DirectoryMatch>
Inside of the DirectoryMatch, I then added:
Code:
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/nagios3$ https://%{SERVER_NAME}%{REQUEST_URI} [L]
But the results were failure - the web browser would still load in usual http. Https would work only if I explicitaly surfed to
https://<myserver/nagios3>.
Finally I tried this variant:
Code:
RewriteEngine on
RewriteBase /nagios3
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L]
but it gave me a very strange side-effect, namely it would pop-up the Basic Authentication window 2 times - first via http, and after successful login - it would rewrite to https and ask me to redo authentication. This, of course, doesn't make sense as the connection is not encrypted during the first authentication.
Any ideas what's wrong? I'm pretty sure problems could be in the fact that Alias (Alias /nagios3 /usr/share/nagios3/htdocs) is being used, and I believe it's harder to make rewrites to work properly on these.
Any feedback is appreciated!
Thanks in advance!
M.