SSL Redirection 5.2.3

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
mikew
Posts: 243
Joined: Sun Feb 05, 2012 7:05 pm

SSL Redirection 5.2.3

Post by mikew »

I have reconfigured an XI server with 5.2.2 but now in 5.2.3 the configuration to redirect SSL is not working.

Any ideas?

Here is what I have:
Certificates built and working. The problem is in the redirection.

/etc/httpd/conf/httpd.conf

Code: Select all

NameVirtualHost *:443  
config.inc.php
set to true;

Systems settings:
Set to https://server_ip/nagiosxi/

Core Config manager set to https

/etc/httpd/conf.d/nagiosxi.conf
I have also tried this line:
Redirect permanent / https://server_ip/
This setting says too many redirections.

The setting below does not place a "/" between the IP and nagiosxi

Code: Select all

<Directory "/usr/local/nagiosxi/html">
#  SSLRequireSSL
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   Redirect permanent / https://server_ip
#  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>



<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/server.crt
        SSLCertificateKeyFile /etc/pki/tls/private/server.key
        <Directory "/usr/local/nagiosxi/html">
        AllowOverride All
        </Directory>
        <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
        </IfModule>
</VirtualHost>

Alias /nagiosxi "/usr/local/nagiosxi/html"
Mike Weber

Nagios Training/Consulting
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: SSL Redirection 5.2.3

Post by lmiltchev »

Make, change:

Code: Select all

Redirect permanent / https://server_ip
to:

Code: Select all

Redirect permanent / https://server_ip/
and restart apache. Did this help?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mikew
Posts: 243
Joined: Sun Feb 05, 2012 7:05 pm

Re: SSL Redirection 5.2.3

Post by mikew »

All that did is is end up saying too many redirections.
Mike Weber

Nagios Training/Consulting
User avatar
lmiltchev
Former Nagios Staff
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: SSL Redirection 5.2.3

Post by lmiltchev »

Mike, what is the OS/architecture? Can you zip up, and PM me the "/usr/local/nagiosxi/html/config.inc.php", and "/etc/httpd/*"?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
mikew
Posts: 243
Joined: Sun Feb 05, 2012 7:05 pm

Re: SSL Redirection 5.2.3

Post by mikew »

Centos 6

When on use the slash on the redirect line that I showed this is what is returned:
Redirect permanent / https://server_ip/

Too many redirects occurred trying to open “https://server_ip/nagiosxi”

Only two lines edited in http.con
ServerName JDTest:80
NameVirtualHost *:443


Only the https line was edited in config.inc.php

// force http/https
$cfg['use_https'] = true; // determines whether cron jobs and other scripts will force the use of HTTPS instead of HTTP

nagiosxi.conf I listed the complete file before. No other files edited in the conf.d directory.
Mike Weber

Nagios Training/Consulting
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: SSL Redirection 5.2.3

Post by WillemDH »

Fyi, as it was on my to do to configure the permanent redirect, I tried to configure it following procedure in https://assets.nagios.com/downloads/nag ... s%20XI.pdf

Seems after restarting httpd, CSS stopped working when surfing to the http link. Also when clicking on 'Access nagios XI' there suddenly is an error in the url resulting in a ERR_NAME_NOT_RESOLVED error..

The resulting url looks like this: https://nagiosservernagiosxi/

I tried this on my PR and QA. Same problem.

Also tried with
Redirect permanent / https://nagiosserver
and
Redirect permanent / https://nagiosserver/
Same result.

This is my whole config:

Code: Select all

<VirtualHost *:80>
        <Directory "/usr/local/nagiosxi/html">
                #  SSLRequireSSL
                Options None
                AllowOverride None
                Order allow,deny
                Allow from all
#                Redirect permanent / https://nagiosserver
                #  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>
        <IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
        </IfModule>
</VirtualHost>
<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/nagiosserver_2016_sha256.crt
        #SSLCertificateFile /etc/pki/tls/certs/nagiosserver.gentgrp.gent.be.crt
        #SSLCertificateFile /etc/pki/tls/certs/ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/nagiosserver_2016_sha256.key
        #SSLCertificateKeyFile /etc/pki/tls/private/nagiosserver.key
        #SSLCertificateKeyFile /etc/pki/tls/private/ca.key
        ErrorLog  /var/log/httpd/ssl_error_log
        CustomLog /var/log/httpd/ssl_access_log combined
        <Directory "/usr/local/nagiosxi/html">
                AllowOverride All
        </Directory>
        <IfModule mod_rewrite.c>
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
        </IfModule>
</VirtualHost>

Alias /nagiosxi "/usr/local/nagiosxi/html"
I don't want to highjack your thread Mike, let me know if you want me to make a separate thread.

Grtz
Nagios XI 5.8.1
https://outsideit.net
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: SSL Redirection 5.2.3

Post by ssax »

I always do this a different way, from the default install in /etc/httpd/conf/httpd.conf I add this to the bottom:

Code: Select all

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
That will handle the rewrites to SSL, then I just define my certs in /etc/httpd/conf.d/ssl.conf, restart apache, make the XI side changes, and it works.


Pro tip:

Add this to the bottom of you /etc/httpd/conf/httpd.conf to enable gzip compression to speed up page loads, ajax request, etc:

Code: Select all

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: SSL Redirection 5.2.3

Post by WillemDH »

Sean,

I'm not sure what Mike's opinion is on this, but imho everyone should use the same method, described in the Nagios XI SSL documentation, which does not work at this time. I prefer to keep working with the nagiosxi.conf Apache configuration file.
The official nagios XI documentation results in two issues when trying a permanent redirect.
- CSS broken when going to HTTP link without fqdn
- Misformed URL (omitted / between Nagios host and nagiosxi suffix

Grtz

Willem
Nagios XI 5.8.1
https://outsideit.net
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: SSL Redirection 5.2.3

Post by ssax »

I agree, the information needs to be updated.

I'll create a task for it on Monday.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: SSL Redirection 5.2.3

Post by ssax »

Mike, please zip up and PM me your /etc/httpd/conf/httpd.conf file and your /etc/http/conf.d directory and I'll lab it up and find you a resolution.

Thank you
Locked