Page 1 of 1

Apache CGI Auth Wrong Server Name

Posted: Tue Apr 23, 2013 9:19 am
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

Re: Apache CGI Auth Wrong Server Name

Posted: Tue Apr 23, 2013 2:05 pm
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?

Re: Apache CGI Auth Wrong Server Name

Posted: Tue Apr 23, 2013 3:20 pm
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.

Re: Apache CGI Auth Wrong Server Name

Posted: Tue Apr 23, 2013 4:02 pm
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

Re: Apache CGI Auth Wrong Server Name

Posted: Thu May 02, 2013 3:43 pm
by mdiorio
No .htaccess files on the server at all.

Re: Apache CGI Auth Wrong Server Name

Posted: Thu May 02, 2013 9:00 pm
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.

Re: Apache CGI Auth Wrong Server Name

Posted: Fri May 03, 2013 8:23 am
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

Re: Apache CGI Auth Wrong Server Name

Posted: Fri May 03, 2013 11:03 am
by sreinhardt
Awesome! Thanks for letting us know it is resolved.