You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Chris Bennett <ch...@bennettconstruction.biz> on 2010/05/19 23:37:08 UTC

Truoble getting Apache::AuthCookie to work on server

After getting it to work just fine on my desktop, without any virtual 
hosts, I can't get it to work right on my server in a virtual host.

Using OpenBSD, older -current, chrooted, all mod_perl
  after adding some debugging warns, I get this

username= cool at /usr/local/libdata/perl5/site_perl/MyPerl/Utils.pm 
line 13.
password = yellow at /usr/local/libdata/perl5/site_perl/MyPerl/Utils.pm 
line 14.

I am not getting correct previous uri: (should be /protected/index.html)

uri = /perl/login.pl at /var/www/htdocs/users/edett.us/perl/login.pl 
line 13.
Use of uninitialized value $creds in concatenation (.) or string at 
/var/www/htdocs/users/edett.us/perl/login.pl line 15.
creds =  at /var/www/htdocs/users/edett.us/perl/login.pl line 15.
Use of uninitialized value $reason in concatenation (.) or string at 
/var/www/htdocs/users/edett.us/perl/login.pl line 36


I have tried with both version 3.12 and 3.14
Thanks
Chris Bennett

-- 
A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects.
    -- Robert Heinlein

Re: Apache2::RequestIO::print: (103) Software caused connection abort at ...

Posted by Nishikant Kapoor <nk...@webrachna.com>.
Torsten Förtsch,

You are awesome! That was it.

I had a line in there just before '$r->print($tmpl->output)'

   $r->content_type("text/html; charset=ISO-8859-1\n\n");

I removed the two \n and now, it is working great with both IE and FF..

Really, truly appreciate it.
Nishi


Torsten Förtsch wrote:
> On Saturday 22 May 2010 15:53:09 Nishikant Kapoor wrote:
>> Hello there,
>>
>> I have been trying to figure it out for over a week now but without much
>> success. Could really use some help.
>>
>> When I visit my site http://www.Channelorama.com/DH/?act=home using IE,
>> I see the following error in the apache error log. And, IE hangs in a
>> 'working' loop, without displaying the page.
>>
>> [Thu May 20 03:01:08 2010] [error] Apache2::RequestIO::print: (103)
>> Software caused connection abort at ...util.pm line 855
>>
>> The line it is complaining about is
>>
>>    $r->print($tmpl->output);
>>
>> The strange part is that this error shows up ONLY when browsing via IE
>> (version 6 and 8; haven't tried others). But, when browsing the same
>> site using FF (3.5.3) on Linux, it seems to be working just fine. No
>> errors in the log.
>>
>> Has anyone experienced this/similar issue? If so, could you please share
>> how you resolved it? Here is my setup:
>>
> 
> Your server claims to do chunked output. That means the first output line 
> contains the length of the first chunk. But it does not obey the protocol.
> 
> $ curl -v 'http://www.channelorama.com/DH/?act=home' --raw 
> * About to connect() to www.channelorama.com port 80 (#0)                                                
> *   Trying 74.126.19.227... connected                                                                    
> * Connected to www.channelorama.com (74.126.19.227) port 80 (#0)                                         
>> GET /DH/?act=home HTTP/1.1                                                                             
>> User-Agent: curl/7.19.6 (x86_64-unknown-linux-gnu) libcurl/7.19.6 
> OpenSSL/0.9.8k zlib/1.2.3 libidn/1.10
>> Host: www.channelorama.com                                                                             
>> Accept: */*                                                                                            
>>                                                                                                        
> < HTTP/1.1 200 OK
> < Date: Sat, 22 May 2010 14:04:20 GMT
> < Server: Apache/2.2.15 (Unix) PHP/5.2.6 mod_perl/2.0.4 Perl/v5.8.8
> < Transfer-Encoding: chunked
> < Content-Type: text/html; charset=ISO-8859-1
> <
>              <-- here the length of the chunk is expected
> 
> 16204        <-- but it only comes here. You print 2 empty lines before the
>                  first chunk
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> 
> 
> Here an example how it should look like:
> 
> $ curl -v 'http://www.bahn.de/p/view/index.shtml' --raw
> * About to connect() to www.bahn.de port 80 (#0)                                                    
> *   Trying 81.200.198.6... connected                                                                
> * Connected to www.bahn.de (81.200.198.6) port 80 (#0)                                              
>> GET /p/view/index.shtml HTTP/1.1                                                                  
>> User-Agent: curl/7.19.6 (x86_64-unknown-linux-gnu) libcurl/7.19.6 
> OpenSSL/0.9.8k zlib/1.2.3 libidn/1.10
>> Host: www.bahn.de                                                                                      
>> Accept: */*                                                                                            
>>                                                                                                        
> < HTTP/1.1 200 OK                                                                                        
> < Date: Sat, 22 May 2010 14:07:44 GMT                                                                    
> < Server: Apache                                                                                         
> < Accept-Ranges: bytes                                                                                   
> < Transfer-Encoding: chunked                                                                             
> < Content-Type: text/html                                                                                
> <                                                                                                        
> 376e             <-- the length of the first chunk is the first line of output
> 
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> 
> Torsten Förtsch
> 


Re: Apache2::RequestIO::print: (103) Software caused connection abort at ...

Posted by Torsten Förtsch <to...@gmx.net>.
On Saturday 22 May 2010 15:53:09 Nishikant Kapoor wrote:
> Hello there,
> 
> I have been trying to figure it out for over a week now but without much
> success. Could really use some help.
> 
> When I visit my site http://www.Channelorama.com/DH/?act=home using IE,
> I see the following error in the apache error log. And, IE hangs in a
> 'working' loop, without displaying the page.
> 
> [Thu May 20 03:01:08 2010] [error] Apache2::RequestIO::print: (103)
> Software caused connection abort at ...util.pm line 855
> 
> The line it is complaining about is
> 
>    $r->print($tmpl->output);
> 
> The strange part is that this error shows up ONLY when browsing via IE
> (version 6 and 8; haven't tried others). But, when browsing the same
> site using FF (3.5.3) on Linux, it seems to be working just fine. No
> errors in the log.
> 
> Has anyone experienced this/similar issue? If so, could you please share
> how you resolved it? Here is my setup:
> 

Your server claims to do chunked output. That means the first output line 
contains the length of the first chunk. But it does not obey the protocol.

$ curl -v 'http://www.channelorama.com/DH/?act=home' --raw 
* About to connect() to www.channelorama.com port 80 (#0)                                                
*   Trying 74.126.19.227... connected                                                                    
* Connected to www.channelorama.com (74.126.19.227) port 80 (#0)                                         
> GET /DH/?act=home HTTP/1.1                                                                             
> User-Agent: curl/7.19.6 (x86_64-unknown-linux-gnu) libcurl/7.19.6 
OpenSSL/0.9.8k zlib/1.2.3 libidn/1.10
> Host: www.channelorama.com                                                                             
> Accept: */*                                                                                            
>                                                                                                        
< HTTP/1.1 200 OK
< Date: Sat, 22 May 2010 14:04:20 GMT
< Server: Apache/2.2.15 (Unix) PHP/5.2.6 mod_perl/2.0.4 Perl/v5.8.8
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=ISO-8859-1
<
             <-- here the length of the chunk is expected

16204        <-- but it only comes here. You print 2 empty lines before the
                 first chunk
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


Here an example how it should look like:

$ curl -v 'http://www.bahn.de/p/view/index.shtml' --raw
* About to connect() to www.bahn.de port 80 (#0)                                                    
*   Trying 81.200.198.6... connected                                                                
* Connected to www.bahn.de (81.200.198.6) port 80 (#0)                                              
> GET /p/view/index.shtml HTTP/1.1                                                                  
> User-Agent: curl/7.19.6 (x86_64-unknown-linux-gnu) libcurl/7.19.6 
OpenSSL/0.9.8k zlib/1.2.3 libidn/1.10
> Host: www.bahn.de                                                                                      
> Accept: */*                                                                                            
>                                                                                                        
< HTTP/1.1 200 OK                                                                                        
< Date: Sat, 22 May 2010 14:07:44 GMT                                                                    
< Server: Apache                                                                                         
< Accept-Ranges: bytes                                                                                   
< Transfer-Encoding: chunked                                                                             
< Content-Type: text/html                                                                                
<                                                                                                        
376e             <-- the length of the first chunk is the first line of output


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Apache2::RequestIO::print: (103) Software caused connection abort at ...

Posted by Nishikant Kapoor <nk...@webrachna.com>.
Hello there,

I have been trying to figure it out for over a week now but without much 
success. Could really use some help.

When I visit my site http://www.Channelorama.com/DH/?act=home using IE, 
I see the following error in the apache error log. And, IE hangs in a 
'working' loop, without displaying the page.

[Thu May 20 03:01:08 2010] [error] Apache2::RequestIO::print: (103) 
Software caused connection abort at ...util.pm line 855

The line it is complaining about is

   $r->print($tmpl->output);

The strange part is that this error shows up ONLY when browsing via IE 
(version 6 and 8; haven't tried others). But, when browsing the same 
site using FF (3.5.3) on Linux, it seems to be working just fine. No 
errors in the log.

Has anyone experienced this/similar issue? If so, could you please share 
how you resolved it? Here is my setup:

CentOS release 5 (Final)
HTML-Template-2.5
Apache/2.2.15 (Unix)  PHP/5.2.6  mod_perl/2.0.4  Perl/v5.8.8

Thanks,
Nishi

Re: Truoble getting Apache::AuthCookie to work on server

Posted by Chris Bennett <ch...@bennettconstruction.biz>.
On 05/20/10 12:12, Perrin Harkins wrote:
> On Thu, May 20, 2010 at 11:12 AM, Chris Bennett
> <ch...@bennettconstruction.biz>  wrote:
>> Well I'm pretty clueless. It works fine on nearly identical desktop at home.
>> Won't work on server.
>
> That means the problem is either different versions on the one that
> doesn't work or a configuration mistake (more likely).  My advice is
> to strip down the configuration on the broken one to something really
> simple that works, and then add things back in a little at a time
> until you find the part that breaks it.
>
> - Perrin

Recently breaking it all into multiple confs was a big help just now.

The problem turned out to be with mod_gzip.


# YES:  CGI scripts
mod_gzip_item_include         file       \.pl$

Excluding this made everything work fine.
So I'm happy now! :)

Can anyone explain to me why this is a problem?
I actually tried in the past to use AuthCookie, but didn't work.
My skills were less, but now I see it couldn't have worked due to this 
problem.

Thanks,
Chris Bennett

Re: Truoble getting Apache::AuthCookie to work on server

Posted by Perrin Harkins <pe...@elem.com>.
On Thu, May 20, 2010 at 11:12 AM, Chris Bennett
<ch...@bennettconstruction.biz> wrote:
> Well I'm pretty clueless. It works fine on nearly identical desktop at home.
> Won't work on server.

That means the problem is either different versions on the one that
doesn't work or a configuration mistake (more likely).  My advice is
to strip down the configuration on the broken one to something really
simple that works, and then add things back in a little at a time
until you find the part that breaks it.

- Perrin

Re: Truoble getting Apache::AuthCookie to work on server

Posted by Chris Bennett <ch...@bennettconstruction.biz>.
Well I'm pretty clueless. It works fine on nearly identical desktop at home.
Won't work on server.

I don't know what else I can try.
I have tried using Location instead of Directory.
Changed module names.
Fiddled with startup.pl
Still always get uri as /perl/login.pl and creds as uninitialized.

Re: Truoble getting Apache::AuthCookie to work on server

Posted by Chris Bennett <ch...@bennettconstruction.biz>.
On 05/19/10 17:11, André Warnier wrote:
> Chris Bennett wrote:
>> After getting it to work just fine on my desktop, without any virtual
>> hosts, I can't get it to work right on my server in a virtual host.
>>
> I have Apache::AuthCookie (and several derived versions) working fine in
> multiple VirtualHost sections, on several servers.
> I just mention this so that you would not think that there is some
> incompatibility between Apache::AuthCookie and VirtualHost setups.
> There isn't.
>
> Apart from that, it is difficult to help you without having any idea of
> your configuration (meaning the main httpd.conf and the virtual hosts
> config, your login form etc..).
>

I am working off the example from mod_perl cookbook

relevant part of startup.pl


use Apache::RegistryBB();
  use Apache::Request();
  use Apache::Cookie();
  use HTML::Entities();
  use Encode();
  use List::Util();
  use Getopt::Std();
  use MIME::Parser();
  use Mail::POP3Client();
  use HTML::Tagset();
  use HTML::Parser();
  use HTML::TreeBuilder();
  #require HTML::FormatText();
  #require B::TerseSize();
  use Cwd();
  use Apache::DBI();
  use DBD::Pg();
  use Carp::Heavy();
  use Exporter();
  use File::Copy();
  use Apache::AuthCookie::Util();
  use Apache::AuthCookie();
  use MyPerl::FormEmail2();
  use MyPerl::FormEmail3();
  use MyPerl::Articulator();
  use MyPerl::ArticulatorBETA();
  use MyPerl::Utils();
  use MyPerl::Authenticate();
###################################################
  use lib qw(/var/www/var/www/htdocs/users/mwforum/cgi/mwf);
  use MwfConfigLSMB();
  use MwfConfigCAPU();
  use MwfMain();
  use MwfConfigGlobal();
  use MwfCGI();
  use MwfDefaults();
  use MwfEnglish();
  use MwfGerman();
  use MwfPlgIncludeCAPU();
  use MwfPlgIncludeLSMB();
  use MwfCaptcha();
use DBD::mysql();
use Carp();
require qw(utf8_heavy.pl);
require qw(unicore/PVA.pl);
require qw(unicore/Exact.pl);
require qw(unicore/Canonical.pl);
require qw(unicore/To/Fold.pl);
require qw(unicore/lib/gc_sc/SpacePer.pl);

  use Apache::Constants();
  use Apache::Connection();
  use Apache::File();
  use Apache::Util();
  use Apache();
  use POSIX();
  use IPC::Run();
  use Digest::MD5();
  use Time::HiRes();
  use GD();
  use Unicode::Normalize();
  use Mail::Sender();
  use MIME::QuotedPrint();

######################################################
#use CGI();
#use CGI::Carp();

require qw(/usr/local/libdata/perl5/site_perl/auto/Image/Size/jpegsize.al);
  use Image::Size();
  use DB_File();



I have httpd.conf split up with individual conf files for gzip, SSL, and 
each virtual host and its SSL, if relevant.


httpd.conf:


#	$OpenBSD: httpd.conf,v 1.19 2006/02/22 15:07:12 henning Exp $
ServerType standalone
ServerRoot "/var/www"
PidFile logs/httpd.pid
ScoreBoardFile logs/apache_runtime_status
Timeout 45
LimitRequestBody 10485760
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
MaxCPUPerChild 0
MaxDATAPerChild 0
MaxNOFILEPerChild 0
MaxRSSPerChild 0
MaxSTACKPerChild 0
Listen *:80
Listen *:8080
Listen *:8081
# Note: The order is which modules are loaded is important.  Don't change
# the order below without expert advice.

# "anonymous" user access to authenticated areas
# LoadModule anon_auth_module	/usr/lib/apache/modules/mod_auth_anon.so

# user authentication using Berkeley DB files
# LoadModule db_auth_module	/usr/lib/apache/modules/mod_auth_db.so

# user authentication using DBM files
# LoadModule dbm_auth_module	/usr/lib/apache/modules/mod_auth_dbm.so

# authentication using new-style MD5 Digest Authentication (experimental)
LoadModule digest_auth_module	/usr/lib/apache/modules/mod_auth_digest.so

# CERN httpd metafile semantics
# LoadModule cern_meta_module	/usr/lib/apache/modules/mod_cern_meta.so

# configuration defines ($xxx)
# LoadModule define_module	/usr/lib/apache/modules/mod_define.so

# user authentication using old-style MD5 Digest Authentication
# LoadModule digest_module	/usr/lib/apache/modules/mod_digest.so

# generation of Expires HTTP headers according to user-specified criteria
# LoadModule expires_module	/usr/lib/apache/modules/mod_expires.so

# customization of HTTP response headers
# LoadModule headers_module	/usr/lib/apache/modules/mod_headers.so

# comprehensive overview of the server configuration
# LoadModule info_module		/usr/lib/apache/modules/mod_info.so

# logging of the client user agents (deprecated in favor of mod_log_config)
# LoadModule agent_log_module	/usr/lib/apache/modules/mod_log_agent.so

# logging of referers (deprecated in favor of mod_log_config)
# LoadModule referer_log_module	/usr/lib/apache/modules/mod_log_referer.so

# determining the MIME type of a file by looking at a few bytes of its 
contents
# LoadModule mime_magic_module	/usr/lib/apache/modules/mod_mime_magic.so

# mmap()ing of a statically configured list of frequently requested but
# not changed files (experimental)
# LoadModule mmap_static_module	/usr/lib/apache/modules/mod_mmap_static.so

# rule-based rewriting engine to rewrite requested URLs on the fly
LoadModule rewrite_module	/usr/lib/apache/modules/mod_rewrite.so

# attempt to correct misspellings of URLs that users might have entered
# LoadModule speling_module	/usr/lib/apache/modules/mod_speling.so

# provides an environment variable with a unique identifier for each request
# LoadModule unique_id_module	/usr/lib/apache/modules/mod_unique_id.so

# uses cookies to provide for a clickstream log of user activity on a site
# LoadModule usertrack_module	/usr/lib/apache/modules/mod_usertrack.so

# dynamically configured mass virtual hosting
# LoadModule vhost_alias_module	/usr/lib/apache/modules/mod_vhost_alias.so

# caching proxy
# LoadModule proxy_module	/usr/lib/apache/modules/libproxy.so

# PHP Module
# LoadModule php4_module        /usr/lib/apache/modules/libphp4.so
# LoadModule php5_module /usr/local/lib/php/libphp5.so

# mod_perl module
LoadModule perl_module        /usr/lib/apache/modules/mod_perl.so
LoadModule gzip_module        /usr/lib/apache/modules/mod_gzip.so

#Do I really need to add this? From External Instructions --Chris
#AddModule mod_vhost_alias.c
#AddModule mod_perl.c
#AddModule mod_gzip.c
#ExtendedStatus On

#
# Include extra module configuration files. from 4.3 OpenBSD httpd.conf 
--Chris
#
Include /var/www/conf/modules/*.conf

### Section 2: 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
Port 443
Port 444
Port 80
Port 8080
Port 8081

PerlRequire /var/www/startup.pl
##
<IfDefine SSL>
Listen 443
Listen 444
</IfDefine>

User www
Group www
ServerAdmin webmaster@bennettconstruction.us
# If your host doesn't have a registered DNS name, enter its IP address 
here.
# You will have to access it by its address (e.g., http://123.45.67.89/)
# anyway, and this will make redirections work in a sensible way.
#
ServerName bennettconstruction.us
PerlTaintCheck	On
DocumentRoot /var/www/var/www/htdocs/users
<Directory />
     Options None
     AllowOverride None
     Order Deny,Allow
     Deny from all
</Directory>

UserDir disabled root

DirectoryIndex index.html
AccessFileName .htaccess

<Files ~ "^\.ht">
     Order allow,deny
     Deny from all
</Files>

UseCanonicalName Off
TypesConfig conf/mime.types
DefaultType text/plain
<IfModule mod_mime_magic.c>
     MIMEMagicFile conf/magic
</IfModule>
#LogLevel debug
LogLevel warn
HostnameLookups Off
ErrorLog logs/error_log
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" 
\"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access_log combined

ServerSignature Off
ServerTokens Prod

#
# Aliases: Add here as many aliases as you need (with no limit). The 
format is
# Alias fakename realname
#
# 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/ "/var/www/icons/"

<Directory "/var/www/icons">
     Options None
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>

<Directory "/var/www/htdocs/manual">
     Options None
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>

Alias /perl/capu/ "/var/www/var/www/htdocs/users/mwforum/cgi/mwf/"
Alias /perl/lsmb/ "/var/www/var/www/htdocs/users/mwforum/cgi/mwf/"
<Directory /mwforum/cgi/mwf>
     Options +ExecCGI +SymLinksIfOwnerMatch +MultiViews
     SetHandler perl-script
     PerlHandler Apache::RegistryBB
     PerlSetupEnv Off
     PerlSendHeader Off
</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/ "/var/www/cgi-bin/"

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

#
# 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
#

#
# Directives controlling the display of server-generated directory listings.
IndexOptions FancyIndexing
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions.  These are only displayed for
# FancyIndexed directories.

AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip

AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*

AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core

AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
#AddDescription "GZIP compressed document" .gz
#AddDescription "tar archive" .tar
#AddDescription "GZIP compressed tar archive" .tgz
ReadmeName README
HeaderName HEADER
# IndexIgnore is a set of filenames which directory indexing should ignore
# and not include in the listing.  Shell-style wildcarding is permitted.
#
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
#
AddEncoding x-compress Z
AddEncoding x-gzip gz
AddLanguage en .en
AddLanguage fr .fr
AddLanguage de .de
AddLanguage da .da
AddLanguage el .el
AddLanguage it .it
AddLanguage es .es
LanguagePriority en es fr de
AddType application/x-httpd-cgi .cgi
AddType application/x-httpd-cgi .pl
AddType application/x-httpd-php .php
AddHandler cgi-script cgi pl
AddType text/html .html
AddHandler server-parsed .html
#
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#

#
# MetaDir: specifies the name of the directory in which Apache can find
# meta information files. These files contain additional HTTP headers
# to include when sending the document
#
#MetaDir .web

#
# MetaSuffix: specifies the file name suffix for the file containing the
# meta information.
#
#MetaSuffix .meta

#
# Customizable error response (Apache style)
#  these come in three flavors
#
#    1) plain text
#ErrorDocument 500 "The server made a boo boo.
#  n.b.  the (") marks it as text, it does not get output
#
#    2) local redirects
#ErrorDocument 404 /missing.html
#  to redirect to local URL /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#  N.B.: You can redirect to a script or a document using 
server-side-includes.
#
#    3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
#  N.B.: Many of the environment variables associated with the original
#  request will *not* be available to such a script.

#
# The following directives modify normal HTTP response behavior.
# The first directive disables keepalive for Netscape 2.x and browsers that
# spoof it. There are known problems with these browser implementations.
# The second directive is for Microsoft Internet Explorer 4.0b2
# which has a broken HTTP/1.1 implementation and does not properly
# support keepalive when it is used on 301 or 302 (redirect) responses.
#
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0

#
# The following directive disables HTTP/1.1 responses to browsers which
# are in violation of the HTTP/1.0 spec by not being able to grok a
# basic 1.1 response.
#
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0

#
# Allow server status reports, with the URL of 
http://servername/server-status
# Change the ".your_domain.com" to match your domain to enable.
#
#<Location /server-status>
#    SetHandler server-status
#    Order deny,allow
#    Deny from all
#    Allow from 70.112.48.107 72.177.54.134
#</Location>

#
# Allow remote server configuration reports, with the URL of
#  http://servername/server-info (requires that mod_info.c be loaded).
# Change the ".your_domain.com" to match your domain to enable.
#
#<Location /server-info>
#    SetHandler server-info
#    Order deny,allow
#    Deny from all
#    Allow from 70.112.48.107 72.177.54.134
#</Location>

PerlModule Apache::DBI

### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them.
# Please see the documentation at <URL:http://www.apache.org/docs/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.

#
# If you want to use name-based virtual hosts you need to define at
# least one IP address (and port number) for them.
#
NameVirtualHost 64.85.161.47:80
NameVirtualHost 64.85.161.48:80
NameVirtualHost 64.85.161.47:8080
#NameVirtualHost 64.85.161.48:443

NameVirtualHost 64.85.161.47:8081
#NameVirtualHost 64.85.161.48:8080

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
#
#<VirtualHost ip.address.of.host.some_domain.com>
#    ServerAdmin webmaster@host.some_domain.com
#    DocumentRoot /www/docs/host.some_domain.com
#    ServerName host.some_domain.com
#    ErrorLog logs/host.some_domain.com-error_log
#    CustomLog logs/host.some_domain.com-access_log common
#</VirtualHost>

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


and conf from virtual host I am using to test

<VirtualHost 64.85.161.47:80>
     DocumentRoot /var/www/var/www/htdocs/users/edett.us
     ServerName edett.us
     ServerAlias www.edett.us
<Directory />
     ErrorDocument 400 /errors/badreq.html
     ErrorDocument 401 /errors/authreqd.html
     ErrorDocument 403 /errors/forbid.html
     ErrorDocument 404 /errors/missing.html
     ErrorDocument 500 /errors/serverr.html
     DirectoryIndex index.html
     AllowOverride FileInfo AuthConfig Limit
     Options -Indexes +SymLinksIfOwnerMatch +IncludesNoExec +ExecCGI 
+MultiViews
     Order allow,deny
     Allow from all
     <Limit GET POST OPTIONS PROPFIND>
         Order allow,deny
         Allow from all
     </Limit>
     <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
         Order deny,allow
         Deny from all
     </Limit>
</Directory>
<Location /ED>
     AllowOverride FileInfo AuthConfig Limit
     Options +Indexes +SymLinksIfOwnerMatch +IncludesNoExec
     Order allow,deny
     Allow from all
     <Limit GET POST OPTIONS PROPFIND>
         Order allow,deny
         Allow from all
     </Limit>
     <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
         Order deny,allow
         Deny from all
     </Limit>
</Location>
PerlModule Apache::Registry
#PerlModule Apache::AuthCookie

<Location /perl>
     SetHandler perl-script
     PerlHandler Apache::Registry::handler
     Options ExecCGI +SymLinksIfOwnerMatch
     PerlSetupEnv Off
</Location>
     PerlModule MyPerl::Authenticate
     PerlSetVar protectedPath /
     PerlSetVar protectedLoginScript /perl/login.pl
     PerlSetVar protectedExpires +1h
<Location /login>
     AuthType MyPerl::Authenticate
     AuthName protected
     SetHandler perl-script
     PerlHandler MyPerl::Authenticate->login
</Location>

<Location /logout>
     AuthType MyPerl::Authenticate
     AuthName protected
     SetHandler perl-script
     PerlHandler MyPerl::Authenticate->logout
</Location>

# These documents require user to be logged in.
<Location /protected>
     AuthType MyPerl::Authenticate
     AuthName protected
     PerlAuthenHandler MyPerl::Authenticate->authenticate
     require valid-user
</Location>

     User ed
     Group ed
</VirtualHost>


and login.pl
#!/usr/bin/perl

use strict;
use warnings;
use mod_perl;

my $r = Apache->request;

# Setting the status to 200 here causes the default apache 403 page to be
# appended to the custom error document.  We understand but the user may not
#$r->status(200);
my $uri = $r->prev->uri;
warn "uri = $uri";
my $creds = $r->prev->pnotes("protectedCreds");
warn "creds = $creds";
# if there are args, append that to the uri
my $args = $r->prev->args;
if ($args) {
     $uri .= "?$args";
}

my $reason = $r->prev->subprocess_env("AuthCookieReason");

my $form = qq{
<html>
<head>
<title>Enter Login and Password</title>
</head>
<body onload="document.forms[0].credential_0.focus();">
};
# output creds in a comment so the test case can see them.
if (defined $creds) {
     $form .= "<!-- creds: @{$creds} -->\n";
}

$form .= qq{
<form method="post" action="/login">
<table width=60% align=center valign=center>
<tr><td align=center>
<h1>This is a secure document</h1>
</td></tr>
<tr><td align=left>
<p>Failure reason: '$reason'.  Please enter your login and password to 
authenticate.</p>
</td>
<tr><td>
<input type=hidden name=destination value="$uri">

</td></tr>
<tr><td>
<table align=center>
<tr>
<td align=right><b>Login:</b></td>
<td><input type="text" name="credential_0" size=10 maxlength=10></td>
</tr>
<tr>
<td align=right><b>Password:</b></td>
<td><input type="password" name="credential_1" size=8 maxlength=8></td>
</tr>
<tr>
<td colspan=2 align=center><input type="submit" value="Continue"></td>
</tr></table>
</td></tr></table>
</form>
</body>
</html>
};
$r->no_cache(1);
my $x = length($form);
$r->content_type("text/html");
$r->headers_out->set("Content-length","$x");
$r->headers_out->set("Pragma", "no-cache");
$r->send_http_header;

$r->print ($form);



Re: Truoble getting Apache::AuthCookie to work on server

Posted by André Warnier <aw...@ice-sa.com>.
Chris Bennett wrote:
> After getting it to work just fine on my desktop, without any virtual 
> hosts, I can't get it to work right on my server in a virtual host.
> 
I have Apache::AuthCookie (and several derived versions) working fine in 
multiple VirtualHost sections, on several servers.
I just mention this so that you would not think that there is some 
incompatibility between Apache::AuthCookie and VirtualHost setups.
There isn't.

Apart from that, it is difficult to help you without having any idea of 
your configuration (meaning the main httpd.conf and the virtual hosts 
config, your login form etc..).