Page 1 of 2

HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 10:52 am
by jkinning
I was originally running with HTTP and have followed these instructions - https://assets.nagios.com/downloads/nag ... s%20XI.pdf to make it HTTPS using a self-sign certificate. I had previously sent out some information on how to login and the URL was http://<server>/nagiosxi/ but whenever someone clicks that link it doesn't work because somewhere it is redirecting to https://<server>nagiosxi/ the https is good but I am missing the / between the server domain url and the nagiosxi. I cannot figure out where or what I need to change to correct that so http://<server>/nagiosxi/ gets redirected to https://<server>/nagiosxi/

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 11:07 am
by ssax
If you followed the guide the redirect should be here: /etc/httpd/conf.d/nagiosxi.conf

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 11:10 am
by ssax
Actually, check the redirect first, but most likely you need to go to Admin > System Config > Manage System Config and add the trailing / at the end of Program URL and/or External URL.

As an example, from this:

Code: Select all

https://YOURSERVER/nagiosxi
To:

Code: Select all

https://YOURSERVER/nagiosxi/

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 11:50 am
by jkinning
I have the trailing / on the Admin > System Config > Manage System Config page.

Here is what I have for the /etc/httpd/conf.d/nagiosxi.conf

Code: Select all

#NameVirtualHost *:443
<VirtualHost *:80> # Add this line
Redirect permanent / https://<nagiosserver>/ -- I also tried Redirect permanent / https://<nagiosserver>/nagiosxi and Redirect permanent / https://<nagiosserver>
<Directory "/usr/local/nagiosxi/html">
# SSLRequireSSL
 Options None
 AllowOverride None
 Order allow,deny
 Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
# AuthName "Nagios XI"
# AuthType Basic
# AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users
# Require valid-user
</Directory>

 # Add this line
</VirtualHost>
<VirtualHost *:443>
 SSLEngine on
 SSLCertificateFile /etc/pki/tls/certs/ca.crt
 SSLCertificateKeyFile /etc/pki/tls/private/ca.key
 <Directory "/usr/local/nagiosxi/html">
 AllowOverride All
 </Directory>
</VirtualHost>
Alias /nagiosxi "/usr/local/nagiosxi/html"

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 12:59 pm
by ssax
If you remove the redirect from that file and then edit /etc/httpd/conf/httpd.conf and put this code at the bottom:

Code: Select all

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Then restart httpd:

Code: Select all

service restart httpd
Does that fix the problem?

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 1:27 pm
by jkinning
Still taking me to https://<nagiosserver>netnagiosxi/

Code: Select all

NameVirtualHost *:443
<VirtualHost *:80> # Add this line
#Redirect permanent / https://<nagiosserver>/
<Directory "/usr/local/nagiosxi/html">
# SSLRequireSSL
 Options None
 AllowOverride None
 Order allow,deny
 Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
# AuthName "Nagios XI"
# AuthType Basic
# AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users
# Require valid-user
</Directory>

 # Add this line
</VirtualHost>
<VirtualHost *:443>
 SSLEngine on
 SSLCertificateFile /etc/pki/tls/certs/ca.crt
 SSLCertificateKeyFile /etc/pki/tls/private/ca.key
 <Directory "/usr/local/nagiosxi/html">
 AllowOverride All
 </Directory>
</VirtualHost>
Alias /nagiosxi "/usr/local/nagiosxi/html"
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 1:31 pm
by ssax
What does the link that you sent out look like? Does it have the / or not? http://<nagiosserver>/nagiosxi

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 1:36 pm
by jkinning
http://<nagiosserver>/nagiosxi/

Something during the change to https is removing the / I just can't figure out what. The link worked fine before switching to https.

Re: HTTP to HTTPS redirect failing

Posted: Tue Jul 21, 2015 1:41 pm
by ssax
Please PM me your /etc/httpd/conf/httpd.conf and your /etc/httpd/conf.d directory so I can take a look.

Re: HTTP to HTTPS redirect failing

Posted: Wed Jul 22, 2015 9:54 am
by ssax
Files received and PM sent with modified configs.