|
Home > Archive > Web Servers on Unix and Linux > September 2006 > prob with apache2 and hostname/servername env variables
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
prob with apache2 and hostname/servername env variables
|
|
|
| I'm having trouble getting apache2 to set env variables like SERVER_NAME
the way I expect.
I have apache2 on simple ubuntu/debian server on a home lan behind an
adsl nat/router.
It is just a test box for my "real" site which is hosted externally. I
only need to access it locally, ie no access from the internet.
I use a "dummy" domain name = "home.lan" which is not exposed to the
internet. My hostname is set to "server3.home.lan" and hostname and
hostname -f both show this correctly.
I am not using virtual hosts, so I just have the main server and in
apache2.conf I set: ServerName server3.home.lan:80
I am NOT using any dns for the home lan, so to access the server I point
to it using the ip address.
Now pretty much everything works just fine, but I have some problems
with some specific php scripts that use apache environment variables.
Using phpinfo() to compare my hosted server with my home server I see
that variables like SERVER_NAME are set to the IP address not fqdn.
Is this because I accessed the site by IP address rather than name?
Or am I missing something in the setup ? The phpinfo output shows the
correct fqdn in the apache2handler section ... and so it seems apache
has detected my hostname/domainname correctly.
Also the hostname seems to be seen correctly by other application
(Postfix for example). It's just apache I'm having trouble with.
I even tried using the SetEnv directive to "force" the variable to the
right value. This works to set a new variable but no surprise this
wouldn't override a standard variable like SERVER_NAME.
Any suggestions where to look?
If the answer is that I have to set up a dns server then that's new
ground for me, can anyone point me to a "howto" that would help me build
a bare minimum setup ... I really only need it to solve this particular
issue.
| |
| Max Dittrich 2006-09-09, 1:17 pm |
| Hi,
Am Fri, 08 Sep 2006 21:47:38 GMT schrieb Geoff:
> I'm having trouble getting apache2 to set env variables like SERVER_NAME
> the way I expect.
>
> I have apache2 on simple ubuntu/debian server on a home lan behind an
> adsl nat/router.
>
> It is just a test box for my "real" site which is hosted externally. I
> only need to access it locally, ie no access from the internet.
>
> I use a "dummy" domain name = "home.lan" which is not exposed to the
> internet. My hostname is set to "server3.home.lan" and hostname and
> hostname -f both show this correctly.
>
> I am not using virtual hosts, so I just have the main server and in
> apache2.conf I set: ServerName server3.home.lan:80
>
> I am NOT using any dns for the home lan, so to access the server I point
> to it using the ip address.
>
> Now pretty much everything works just fine, but I have some problems
> with some specific php scripts that use apache environment variables.
> Using phpinfo() to compare my hosted server with my home server I see
> that variables like SERVER_NAME are set to the IP address not fqdn.
>
> Is this because I accessed the site by IP address rather than name?
>
> Or am I missing something in the setup ? The phpinfo output shows the
> correct fqdn in the apache2handler section ... and so it seems apache
> has detected my hostname/domainname correctly.
>
> Also the hostname seems to be seen correctly by other application
> (Postfix for example). It's just apache I'm having trouble with.
>
> I even tried using the SetEnv directive to "force" the variable to the
> right value. This works to set a new variable but no surprise this
> wouldn't override a standard variable like SERVER_NAME.
>
> Any suggestions where to look?
Check the value of "UseCanonicalName" in your configuration. Setting it to
"On" may fix your problem.
See http://httpd.apache.org/docs/2.0/mo...secanonicalname for
details.
..max
|
|
|
|
|