httpshttpd.conf

why my http redirect don't work with nagios?


I have a webserver with nagios, nagios is the only service working in this vm, so I want when I go to the root https://mymachine to redirect directly to https://mymachine/nagios. I have made a configuration like this

<VirtualHost *:443>
   ServerName mymachine.mydomain
   ServerAdmin root@mymachine.mydomain
   Redirect / https://mymachine.mydomain/nagios
   # SSL Engine Switch:
   # Enable/Disable SSL for this virtual host.
   SSLEngine on
   SSLCertificateFile /etc/pki/tls/certs/nagios1.mymachine.mydomain.crt
   SSLCertificateKeyFile /etc/pki/tls/private/nagios1mymachine.mydomain.key
   SSLCACertificateFile /etc/pki/tls/certs/mymachine.mydomain.crt
</VirtualHost>
          

Restart http and..disaster! Firefox open the page

https://nagios1.mymachine.mydomain/nagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagios

and give the "redirect loop" error. Consider I have also a redirect from http to https active

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

If I remove it is the same thing. Any solution? Thanks


Solution

  • Solution found.

    <VirtualHost *:80>
       ServerName nagios1.mymachine.mydomain
       ServerAdmin root@mymachine.mydomain
       Redirect "/" "https://nagios1.mymachine.mydomain/nagios"
    </VirtualHost>
    
    <VirtualHost *:443>
          # SSL Engine Switch:
       # Enable/Disable SSL for this virtual host.
       SSLEngine on
       SSLCertificateFile /etc/pki/tls/certs/nagios1.mymachine.mydomain.crt
       SSLCertificateKeyFile /etc/pki/tls/private/nagios1mymachine.mydomain.key
       SSLCACertificateFile /etc/pki/tls/certs/mymachine.mydomain.crt
    </VirtualHost>