LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-02-2003, 08:38 AM   #1
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
Getting mad of apache


I try to reach a virtual host inside our LAN, which is defined by name ("safehttp.foo.bar") in httpd.conf, but when I type "http://safehttp.foo.bar/" I am taken to directory "/usr/local/www/Web/intranet" instead of the DocumentRoot ("/usr/local/www/Web") I specified in the virtual host definition.

So it looks like the DocumentRoot definition for the safehttp.foo.bar VirtualHost is completely ignored by apache.

What is misconfigured?

Here is an excerpt of my httpd.conf:

# ServerType is either inetd, or standalone. Inetd mode is only supported on
# Unix platforms.
#
ServerType standalone
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/usr/local"
# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e., use
# "www" instead of the host's real name).
# RewriteEngine on
# RewriteCond %(REMOTE_HOST) !^.+\.meei\.hu$
# RewriteRule ^(/~.+) https://mail.foo.bar$1 [R,L]
#ServerName new.host.name
ServerName castor.foo.bar
#
# 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/www/data"
DocumentRoot "/usr/local/www/Web"
#
# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# permissions.
#
<Directory />
Options +Includes FollowSymLinks
AllowOverride None
</Directory>
#
# This should be changed to whatever you set DocumentRoot to.
#
#<Directory "/usr/local/www/data">
<Directory "/usr/local/www/Web">
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
Options Indexes FollowSymLinks MultiViews +Includes

#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride AuthConfig

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>

#
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is received.
#
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec +Includes
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>


#
# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
# Apache needs to construct a self-referencing URL (a URL that refers back
# to the server the response is coming from) it will use ServerName and
# Port to form a "canonical" name. With this setting off, Apache will
# use the hostnameort that the client supplied, when possible. This
# also affects SERVER_NAME and SERVER_PORT in CGI scripts.
#
UseCanonicalName On

#
# TypesConfig describes where the mime.types file (or equivalent) is
# to be found.
#
<IfModule mod_mime.c>
TypesConfig /usr/local/etc/apache/mime.types
</IfModule>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value. If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type. The MIMEMagicFile
# directive tells the module where the hint definitions are located.
# mod_mime_magic is not part of the default server (you have to add
# it yourself with a LoadModule [see the DSO paragraph in the 'Global
# Environment' section], or recompile the server and include mod_mime_magic
# as part of the configuration), so it's enclosed in an <IfModule> container.
# This means that the MIMEMagicFile directive will only be processed if the
# module is part of the server.
#
<IfModule mod_mime_magic.c>
MIMEMagicFile /usr/local/etc/apache/magic
</IfModule>

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

#
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
<IfModule mod_alias.c>

#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL. So "/icons" isn't aliased in this
# example, only "/icons/"..
#
Alias /icons/ "/usr/local/www/icons/"

<Directory "/usr/local/www/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/usr/local/www/cgi-bin/"

#
# "/usr/local/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/usr/local/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

</IfModule>
# End of aliases.

#
# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Format: Redirect old-URI new-URL
#

### Section 3: Virtual Hosts
#
# If you want to use name-based virtual hosts you need to define at
# least one IP address (and port number) for them.
#
#NameVirtualHost 12.34.56.78:80
#NameVirtualHost 12.34.56.78
NameVirtualHost 192.168.226.2

<VirtualHost 192.168.226.2>
ServerAdmin berta@castor.foo.bar
DocumentRoot /usr/local/www/Web/intranet
ServerName intranet.foo.bar
<Directory />
Options Indexes FollowSymLinks +Includes
</Directory>
ErrorLog /var/log/intranet-error.log
</VirtualHost>

<VirtualHost 192.168.226.2>
ServerAdmin berta@castor.foo.bar
DocumentRoot /usr/local/www/Web/public_html
ServerName public.foo.bar
<Directory />
Options Indexes FollowSymLinks +Includes
</Directory>
ErrorLog /var/log/intranet-error.log
</VirtualHost>

<VirtualHost 192.168.226.2>
ServerAdmin berta@castor.foo.bar
DocumentRoot /usr/local/www/Web
ServerName mail.foo.bar
<Directory />
Options +Indexes FollowSymLinks +Includes
</Directory>
ErrorLog /var/log/intranet-error.log
</VirtualHost>

<VirtualHost 192.168.226.2>
ServerAdmin berta@castor.foo.bar
DocumentRoot /usr/local/www/Web
ServerName castor.foo.bar
<Directory />
Options +Indexes FollowSymLinks +Includes
</Directory>
ErrorLog /var/log/intranet-error.log
</VirtualHost>

<VirtualHost 192.168.226.2>
ServerAdmin szucs@foo.bar
DocumentRoot /usr/local/www/Web
ServerName safehttp.foo.bar
ErrorLog /var/log/safehttp-error.log
TransferLog /var/log/safehttp-transfer.log
ScriptAlias /cgi-bin/ /usr/local/www/cgi-bin/
Alias /downloads/ "/usr/local/www/Web/downloads/"
<Directory "/usr/local/www/Web/downloads">
Options +Indexes FollowSymLinks +Includes
</Directory>
</VirtualHost>

#<VirtualHost _default_:*>
#</VirtualHost>

Last edited by J_Szucs; 10-02-2003 at 08:54 AM.
 
Old 10-02-2003, 09:15 AM   #2
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Meanwhile I created directory /usr/local/www/Web/safehttp, and also added the directory definition in httpd.conf.

Now the virtual host definition of safehttp.foo.bar is like others that work.

This one does not work and I do not know why.

Last edited by J_Szucs; 10-02-2003 at 09:18 AM.
 
Old 10-02-2003, 02:12 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
Have you restarted apache?
 
Old 10-02-2003, 10:55 PM   #4
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
A hundred times in the past day of debugging...
 
Old 10-03-2003, 02:18 AM   #5
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
I know my apache config is messed up, but this actual problem was due to my browser (ie6):
When it is set to use a proxy and it sees that a page is unavailable the first time, it will always return the page unavailable message even if I click the refresh button. So I had to delete all local temporary files, then set my browser not to use the proxy, then to use the proxy again, and the directory showed up.

However, I still have many problems:
I have a cgi script safehttp.foo.bar/cgi-bin/viralator.cgi, that is called by a redirect rule in squirm.patterns. The script is always called from within safehttp.foo.bar/cgi-bin/, and it downloads a file from the web into safehttp.foo.bar/downloads/. If the download is successful, it gives the url to the client, and makes it start an automatic download. This download, however, always fails, as the client gets url intranet.foo.bar/download/filename as the download filename.
So, the virtual server name changes from safehttp to intranet meanwhile.
I could temporarily solve the matter by symlinking safehttp/download to intranet/download, this, however, is not the correct solution.

Because of such strange changes in the virtual hostnames, in my effort to make things work somehow, I already had to make many symlinks from anywhere to anywhere in the past; so my DocumentRoots now contain scripts, my cgi-bin directories contain documents and icons; php scripts only work in DocumentRoots, while .pl scripts work in /cgi-bin/, too, but their references point out to other virtual hosts; so the whole thing is messed up as it is.

Why are virtual host references changed during the communication between the server and the clients?

Last edited by J_Szucs; 10-03-2003 at 02:21 AM.
 
Old 10-04-2003, 01:42 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
The server will always send back the name by which it was accessed. Perhaps you need to make sure it is always accessed as safehttp with what ever link you use to start with or during the script process.
 
Old 10-04-2003, 04:40 PM   #7
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Original Poster
Rep: Reputation: 58
Quote:
Perhaps you need to make sure it is always accessed as safehttp with what ever link you use to start with or during the script process.
Naturally, I made it sure:
The script is invoked the first time from squid (and squirm), via an url rewrite rule, where any url ending e.g. with .exe is rewritten to point to the script, so the safehttp.foo.bar server name is hardcoded in the rewritten url. Because of this, there is no problem with the first invocation of the script; it is always successful.
The problem is that the script generates pages and places hyperlinks or other references to itself or to files on the same server on these generated pages, which references all seem to point to the wrong servername.
When placing these references on any generated page, the script relies on apache: it uses the "servername" server variable provided by apache. So, I think it is apache to be blaimed.
I could edit the perl script and hardcode the safehttp.foo.bar servername in it, but I need a more general solution, as the problem not only concerns this script, but all scripts in any virtual servers defined.

Last edited by J_Szucs; 10-04-2003 at 04:45 PM.
 
Old 10-05-2003, 06:51 AM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
That is what I meant by "during the script process". Perhaps you could use the referer attribute. Will that always tell you the name of the server that made the inital request?
 
Old 11-21-2003, 01:47 AM   #9
rajbaxi
Member
 
Registered: Jul 2003
Location: MI
Distribution: redhat,mandrake,debian
Posts: 68

Rep: Reputation: 15
Have you checked permissions on the directory? Maybe the virtualhost can't resolve safehttp.foo.bar and it goes back to the default page? Are you running a DNS server?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
which one-dont get mad ekips_zbuhc Linux - Newbie 3 11-29-2005 10:52 PM
DNS is on a mad one sfahey Linux - Networking 1 11-18-2003 06:52 PM
:mad: Installation prob :mad: soodvarun Red Hat 0 09-12-2003 01:44 AM
font gone mad?? graffitici Linux - Software 0 09-04-2003 03:07 PM
Need help...about to go mad!!! ludwig W Linux - General 2 03-26-2003 05:45 PM


All times are GMT -5. The time now is 08:28 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration