Apache CGI Auth Wrong Server Name

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
mdiorio
Posts: 6
Joined: Wed Apr 25, 2012 8:17 am

Apache CGI Auth Wrong Server Name

Post by mdiorio »

Hi Folks,

Our previous admin has a Nagios box set up with hostname gshqmon01.domainname.net. However the system is accessed internally by http://nagios
There is a php redirect in /var/www/html/index.php that will redirect users to http://nagios/nagios

This has worked just fine. We recently have to change the access URL to FQDN. I changed the redirect to point to http://nagios.domainname.net/nagios, and while it's successfully redirecting, HTTP basic Auth is now acting strange. I'm required to log in twice; one for the main site, and once for the CGI. Both have the same Auth Realm Name.

For some reason, when you view the basic auth login box for the main site, you'll see: "The server nagios.globalspec.net at Nagios Access requires a username and password"
However when you get the auth login box for the CGI access, it'll show as: "The server nagios at Nagios Access requires a username and password"

Why is the CGI server name different than the site username? It doesn't matter which URL I access the site via, for example, if I use http://gshqmon01.domainname.net/nagios, CGI server name is still nagios.

Any help is greatly appreciated.

Thanks!

Max
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Apache CGI Auth Wrong Server Name

Post by sreinhardt »

Did you alter all of the nagios virtual host\directories within the apache configuration to accept the new name? Also altering the ServerName value in the apache conf may help. Does this happen when accessing internally as well as externally?
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
mdiorio
Posts: 6
Joined: Wed Apr 25, 2012 8:17 am

Re: Apache CGI Auth Wrong Server Name

Post by mdiorio »

What would need to change? Apache isn't set up for virtual hosts, just alias directories, and the directories didn't change names. The nagios.conf file in http.d remains completely unchanged from the default Nagios install. It's essentially a stock install that hasn't been modified. I did change the servername value in apache conf.d with no results, it was commented out before.

It happens no matter which domain you access it from.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Apache CGI Auth Wrong Server Name

Post by abrist »

Do you have more than one .htaccess file? (one on the www root and another in the nagios www folder?)
What are the contents of those files?

Code: Select all

find / -name .htaccess
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
mdiorio
Posts: 6
Joined: Wed Apr 25, 2012 8:17 am

Re: Apache CGI Auth Wrong Server Name

Post by mdiorio »

No .htaccess files on the server at all.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Apache CGI Auth Wrong Server Name

Post by scottwilkerson »

This is not a problem on the server, per-se, it is browser security.

Previously, you were redirecting

Code: Select all

http://nagios/ -> http://nagios/nagios 
and your browser says, "this is the same domain with the same AuthName, I'll send the same credentials in the request"

Now you are redirecting

Code: Select all

http://nagios/ ->  http://nagios.domainname.net/nagios 
and your browser says to itself "I have credentials for http://nagios/ but I haven't saved credential for http://nagios.domainname.net/ yet, I'm not going to make the mistake of sending these credentials to the wrong server."

I would imaging if you typed http://nagios.domainname.net in the browser it would not request the double authentication.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
mdiorio
Posts: 6
Joined: Wed Apr 25, 2012 8:17 am

Re: Apache CGI Auth Wrong Server Name

Post by mdiorio »

I finally figured out the issue...

It was a hardcoded URL issue in a php file that our architect put in instead of using relative path.

He modified main.php to load tac.cgi directly, but hard coded the URL to http://nagios/nagios/cgi-bin/tac.cgi

I changed it to use the relative path of cgi-bin/tac.cgi and we’re all working happily again.

Thanks for those who tried to help!

Max
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Apache CGI Auth Wrong Server Name

Post by sreinhardt »

Awesome! Thanks for letting us know it is resolved.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked