HTTP to HTTPS redirect failing

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

HTTP to HTTPS redirect failing

Post 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/
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post by ssax »

If you followed the guide the redirect should be here: /etc/httpd/conf.d/nagiosxi.conf
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post 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/
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: HTTP to HTTPS redirect failing

Post 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"
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post 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?
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: HTTP to HTTPS redirect failing

Post 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}
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post by ssax »

What does the link that you sent out look like? Does it have the / or not? http://<nagiosserver>/nagiosxi
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: HTTP to HTTPS redirect failing

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post by ssax »

Please PM me your /etc/httpd/conf/httpd.conf and your /etc/httpd/conf.d directory so I can take a look.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: HTTP to HTTPS redirect failing

Post by ssax »

Files received and PM sent with modified configs.
Locked