Very weird webserver problem

Lukas

Real Name No Gimmicks
Joined
30 Jan 2002
Messages
421
Hi guys,


This is weird...

I have an Apache webserver running on my Linux machine. When I try to connect to the website it hosts @ http://lukass.no-ip.org/ it works like a charm.

Now when I type an address of a subdirectory or click on a link pointing to that subdirectory, a faulty name resolution occurs, and the address changes to http://phantom.realm.home/subdir/ and I get a bad gateway error.

PHANTOM is the hostname of my Linux machine, and I also run a DNS server and active directory (domain realm.home) on my Win2k3. So as long as I'm @ home the problem doesn't bother me. But this also occurs when I try to view the website from other coputers, like my machine @ work, or @ school... This sux, and I really don't know how that could be possible... It happens like 40% - 60% of the time.

Any idea how to fix it? I thought about denying name resolution to the wan address, but I can't do that, coz the LAN address of my router is 10.0.0.138, and the dns server listens on the 10.-range...



Hope you guys can help,


Greetz



Lukas
 
I think this is due to a very strange quirk Apache had (for some reason or other), but seems to be gone in newer versions. If it got a url to a directory containing a trailing slash ( http://your.site/path/ ) everything was fine. But if it did not contain the trailing slash ( http://your.site/path ) the server would redirect the client to the same url, but this time with the trailing slash included. The problem was that the host name for the server wasn't taken from the url it was given, it was taken from the host name that the server thought it had. That's why it redirects to the internal name of the server rather than the external dynamic dns name. The workaround is to remember to always supply the trailing slash in links to directories.

I checked your site and this is exactly what happens:
http://lukass.no-ip.org/blog/ vs
http://lukass.no-ip.org/blog

This is at least how it was explained to me. It seems newer Apache don't have this problem. Which version are you running?
 
Hey Zedric...


Nice work man! Thnx!!!


Greetz


Lukas
 
you could also create a virtual host entry pointing to the web root folder with the servername of your dyndns domain name
 
Apache version:

Apache-AdvancedExtranetServer/2.0.47 (Mandrake Linux/6mdk) mod_perl/1.99_09 Perl/v5.8.1 mod_ssl/2.0.47 OpenSSL/0.9.7b PHP/4.3.2 Server at phantom.realm.home Port 80

killa_bunny, I just started using Linux. Do you know a good httpd.conf - "tutorial"? Need to be very high n00b-level tutorial...


How do I know which conf file is beeing used?

/etc/httpd/conf/commonhttpd.conf
/usr/share/ADVX/compat/httpd.conf
/usr/local/apache2/conf/httpd.conf

Plus: in the httpd.conf the webserver root is loacted @ /usr/local/apache2/htdocs
Code:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/usr/local/apache2/htdocs"
but my root is in
/var/www/html

how come?



thnx guys,


Lukas
 
basic virtual host is in Section 3, here is what it looks like in my httpd.conf file

Code:
### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog /var/log/dummy-host.example.com-error_log
#    CustomLog /var/log/dummy-host.example.com-access_log common
#</VirtualHost>

Things you have to change to get NameBased Virtual Hosting to work
1) Uncomment the line
Code:
#NameVirtualHost *:80
to
Code:
NameVirtualHost *:80

2) Uncomment the VirtualHost area (you can make a copy of it and then uncomment that, so that you have the original as a default to base other vhosts on
Code:
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog /var/log/dummy-host.example.com-error_log
#    CustomLog /var/log/dummy-host.example.com-access_log common
#</VirtualHost>
to
Code:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com dummy-host
#    ErrorLog /var/log/dummy-host.example.com-error_log
#    CustomLog /var/log/dummy-host.example.com-access_log common
</VirtualHost>

Now edit the ServerAdmin line to your email address, or admin@mybox.lan or something, the DocumentRoot, change to where your web documents are such as /var/www/virtualhost/html or /var/www/html if you want a vhost for your web root, change the ServerName to the name that you want the vhost to respond to. ServerAlias is a space separated list of aliases for the Virtual Host to respond to. I usually use a domain name with no www prefix for the ServerName and then put the name with the www prefix in the ServerAlias. I usually leave the ErrorLog and CustomLog commented and let apache log to its normal directory

Thats about it really, if you want more information then take a look at the Apache Docs: VirtualHost section
 
[offtopic]
I would upgrade your apache and php versions. apache2 is at 2.0.50 and php is at 4.3.8, this includes necessary security fixes.
[/offtopic]

From your previous message about phantom.realm.home, you need to turn Canonical Hostname parameter to off in httpd.conf

Code:
# 
# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
# 
UseCanonicalName Off
 
@Killa_Bunny,

Thnx man, great stuff... Which httpd.conf should I edit? The one in /usr/local/apache2/conf/httpd.conf seems to me as the best bet... :D



@ j79zlr

I was thinking about upgrading, but I really don't know how. When I try to use an php rpm it says that the package conflicts with my allready installed package.

Is there a simple (read: for n00bs) way to upgrade apache, php & mysql? Like a rpm command? I'm just too lazy to read man rpm... I tried, but I don't understand the half of it...

Do software updates exist for Apache? Something like Windows has (damn, that sounds so lame :D)

Thnx


Greetz,


L.
 
Ok, I've looked into the online manual for installing apache.

Now my problem is that I don't know what ./configure prefixes to set...

Upgrading from one minor version to the next (for example, from 2.0.55 to 2.0.57) is easier. The make install process will not overwrite any of your existing documents, log files, or configuration files. In addition, the developers make every effort to avoid incompatible changes in the configure options, run-time configuration, or the module API between minor versions. In most cases you should be able to use an identical configure command line, an identical configuration file, and all of your modules should continue to work. (This is only valid for versions after 2.0.41; earlier versions have incompatible changes.)

If you kept the source tree from your last installation, upgrading is even easier. The file config.nice in the root of the old source tree contains the exact configure command line that you used to configure the source tree. Then to upgrade from one version to the next, you need only copy the config.nice file to the source tree of the new version, edit it to make any desired changes, and then run:

Code:
$ ./config.nice
$ make
$ make install
$ PREFIX/bin/apachectl stop
$ PREFIX/bin/apachectl start

I dont have a copy of the config.nice, and I don't know which modules are installed... How can I check the current configuration?
 
Lukas said:
Thnx man, great stuff... Which httpd.conf should I edit? The one in /usr/local/apache2/conf/httpd.conf seems to me as the best bet... :D
The one in /etc should be the one that's used, but I can't guarrantee it. But it seems unlikely that it's one of the others.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back