You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bob Schell <sc...@gmail.com> on 2009/10/16 19:05:47 UTC

[users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Hello.  I have configured my RHEL5 Apache system with SSL.  I verified that
SSL was installed correctly and accessing the site via SSL works as expected
with the one exception described below.

The problem I am having is my PHP code is pulling the
$_SERVER['SERVER_PORT'] variable and this is coming back as 80 rather than
443.  To narrow this problem down, I've closed port 80 by commenting out
'LISTEN 80' so my server is ONLY listening on port 443.  I've verified this
via a port scan of my server ... 443 is open, 80 is not.

Here is my <VIRTUALHOST> code within HTTPD.CONF


NameVirtualHost *:443

:

:

:

<VirtualHost *:443>

ServerAdmin first.name@xyz.com

DocumentRoot /var/www/html/redcap

ServerName name.url.edu

ErrorLog logs/<filename>

CustomLog logs/<filename>
</VirtualHost>

I can get 443 to be returned from _SERVER['SERVER_PORT'] if I edit the 3rd
line above to :

ServerName name.url.edu:443

But, if I do this, it messes a few other things up internal to the site.

Does anyone have an idea why _SERVER['SERVER_PORT'] is returning 80 rather
than 443?

Any thoughts would be much appreciated.

Regards,

Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Bob Schell <sc...@gmail.com>.
Thanks again Eric.  Once I moved the SSL virtual host within SSL.CONF, that
did the trick and everything worked as expected.

Much appreciated.

On Fri, Oct 16, 2009 at 12:16 PM, Eric Covener <co...@gmail.com> wrote:

> On Fri, Oct 16, 2009 at 2:02 PM, Bob Schell <sc...@gmail.com> wrote:
> > Thanks again for the quick reply.  How did my config also imply http over
> > 443?
> >
> > On Fri, Oct 16, 2009 at 11:51 AM, Eric Covener <co...@gmail.com>
> wrote:
> >>
> >> On Fri, Oct 16, 2009 at 1:48 PM, Bob Schell <sc...@gmail.com>
> wrote:
> >> > However, then, within the application I am using, if I logout of the
> >> > application and/or navigate around as I used to be able to do, I get
> the
> >> > following URL which errors out on me:
> >> >
> >> > http://name.url.edu:443/rcsurvey/rp_survey/1.3.1/
> >> >
> >> > You can see that it tacked on the ':443' and changed https to http.
> >>
> >> Your config also implied http over 443 which is unusual.  A redirect
> >> to that protocol and port seems pretty natural.
>
> Normally an SSL virtual host has SSL directives in it.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Eric Covener <co...@gmail.com>.
On Fri, Oct 16, 2009 at 2:02 PM, Bob Schell <sc...@gmail.com> wrote:
> Thanks again for the quick reply.  How did my config also imply http over
> 443?
>
> On Fri, Oct 16, 2009 at 11:51 AM, Eric Covener <co...@gmail.com> wrote:
>>
>> On Fri, Oct 16, 2009 at 1:48 PM, Bob Schell <sc...@gmail.com> wrote:
>> > However, then, within the application I am using, if I logout of the
>> > application and/or navigate around as I used to be able to do, I get the
>> > following URL which errors out on me:
>> >
>> > http://name.url.edu:443/rcsurvey/rp_survey/1.3.1/
>> >
>> > You can see that it tacked on the ':443' and changed https to http.
>>
>> Your config also implied http over 443 which is unusual.  A redirect
>> to that protocol and port seems pretty natural.

Normally an SSL virtual host has SSL directives in it.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Bob Schell <sc...@gmail.com>.
Thanks again for the quick reply.  How did my config also imply http over
443?

On Fri, Oct 16, 2009 at 11:51 AM, Eric Covener <co...@gmail.com> wrote:

> On Fri, Oct 16, 2009 at 1:48 PM, Bob Schell <sc...@gmail.com> wrote:
> > However, then, within the application I am using, if I logout of the
> > application and/or navigate around as I used to be able to do, I get the
> > following URL which errors out on me:
> >
> > http://name.url.edu:443/rcsurvey/rp_survey/1.3.1/
> >
> > You can see that it tacked on the ':443' and changed https to http.
>
> Your config also implied http over 443 which is unusual.  A redirect
> to that protocol and port seems pretty natural.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Eric Covener <co...@gmail.com>.
On Fri, Oct 16, 2009 at 1:48 PM, Bob Schell <sc...@gmail.com> wrote:
> However, then, within the application I am using, if I logout of the
> application and/or navigate around as I used to be able to do, I get the
> following URL which errors out on me:
>
> http://name.url.edu:443/rcsurvey/rp_survey/1.3.1/
>
> You can see that it tacked on the ':443' and changed https to http.

Your config also implied http over 443 which is unusual.  A redirect
to that protocol and port seems pretty natural.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Bob Schell <sc...@gmail.com>.
Thanks for the quick response Eric.  Well, if I add :

'UseCanonicalPhysicalPort On'

I can then keep my 3rd line within <virtualhost *:443> be :

ServerName name.url.edu (without the :443)

And I DO get the proper port returned.

However, then, within the application I am using, if I logout of the
application and/or navigate around as I used to be able to do, I get the
following URL which errors out on me:

http://name.url.edu:443/rcsurvey/rp_survey/1.3.1/

You can see that it tacked on the ':443' and changed https to http.

Any thoughts?


On Fri, Oct 16, 2009 at 11:12 AM, Eric Covener <co...@gmail.com> wrote:

> On Fri, Oct 16, 2009 at 1:05 PM, Bob Schell <sc...@gmail.com> wrote:
> > The problem I am having is my PHP code is pulling the
> > $_SERVER['SERVER_PORT'] variable and this is coming back as 80 rather
> than
> > 443.  To narrow this problem down, I've closed port 80 by commenting out
> > 'LISTEN 80' so my server is ONLY listening on port 443.  I've verified
> this
> > via a port scan of my server ... 443 is open, 80 is not.
>
> There was a thread about this today on this very list, have you tried
> the solution there?
>
> http://marc.info/?l=apache-httpd-users&m=125569605710861&w=2
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Incorrect $_SERVER['SERVER_PORT'] Returned

Posted by Eric Covener <co...@gmail.com>.
On Fri, Oct 16, 2009 at 1:05 PM, Bob Schell <sc...@gmail.com> wrote:
> The problem I am having is my PHP code is pulling the
> $_SERVER['SERVER_PORT'] variable and this is coming back as 80 rather than
> 443.  To narrow this problem down, I've closed port 80 by commenting out
> 'LISTEN 80' so my server is ONLY listening on port 443.  I've verified this
> via a port scan of my server ... 443 is open, 80 is not.

There was a thread about this today on this very list, have you tried
the solution there?

http://marc.info/?l=apache-httpd-users&m=125569605710861&w=2

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org