Re: Apache::ASP - I think bug...

1999-12-09 Thread BeerBong

Btw, I use Apache::ASP 0.17

 Your 2 server configuration has nothing to do with Apache::ASP
 errors.  However, depending on the ProxyPass used at the front
 server, you may end up with varying VirtualHosts handling
 the request on the backend server, so make sure you are connecting
 to the same vhost that the front end accelerator points at.

I'm sure that I'm connecting to the same vhost. I totally have 2 virtual
sites, therefore 2 vhost on simple and 2 vhost on power Apache. Other
virtual site doesn't have scripts with the same names, and therefore will
answer Not Found, if frontend server passes to other backend server.
--
Macro proxy_macro $ip $port
IfDefine simple
RewriteEngine On
RewriteLogLevel 0
RewriteRule ^/((cgi-bin/|perl/|cgi-perl/).*)$ http://$ip:$port/$1
[P,L]
RewriteRule ^/(.*\.(pl|shtml|asp))$   http://$ip:$port/$1
[P,L]

ProxyPassReverse   / http://$ip:$port/
/IfDefine
/Macro

Macro asp_script_macro $host $Debug
IfDefine power
PerlSetVar IncludesDir /usr/web/inc
Files ~ (\.shtml)
   SetHandler perl-script
   PerlHandler Apache::ASP
   PerlSetVar Debug $Debug
   PerlSetVar Global /usr/web/$host/global
   PerlSetVar NoState 1
   PerlSetVar DynamicIncludes 1
/Files
/IfDefine
/Macro

Macro vhost_editor $ip $directory $port1 $port2 $Debug
IfDefine simple
   Listen $ip:$port1
VirtualHost $ip:$port1
/IfDefine
IfDefine power
   Listen $ip:$port2
VirtualHost $ip:$port2
   PerlPostReadRequestHandler My::ProxyRemoteAddr
/IfDefine

   ServerName $directory
   DocumentRoot /usr/web/$directory/data

   Use no_users_macro
   Use asp_script_macro $directory $Debug
   Use proxy_macro $ip $port2
   Use log_macro $directory
   Use auth_macro $directory $directory

IfDefine simple
/VirtualHost
/IfDefine
IfDefine power
/VirtualHost
/IfDefine
/Macro

--


 
   Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
  while "strict refs" in use at (eval 13) line 14.
  , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142
 

 You have use strict enabled, so you need to work through this
 error.  use strict error handling needs some work still, and
 dealing with them in Apache::ASP is fairly new business.

Joshua, this output
--
Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
  while "strict refs" in use at (eval 13) line 14.
--
is sent by another not completed script - rubrics.shtml, when I request
index.shtml! I tried to request 778 port while I'm writing rubrics.shtml


  After some refreshes - I got another output, which is not done by
  index.shtml!

 This sounds like a browser cache problem, make sure you hit
 shift+refresh (Netscape) or control-refresh(IE) to really reload
 a page.

I know what are browser cache problems :) Not it is not browser cache
problem, because after restarting Apache -browser and server works correct
after even 1000 requests, until I request 778 port.

 This could also be a bad mix of Apache::ASP  use strict
 errors.  Can you get me some code that reproduces this behavior?

Yes, I can, but I think it is not a cause of problem, because after restart
Apache
(I leave rubrics.shtml with silly error

my $sth_rubrics = my_prepare("select
level,rubric_id,parent_id,type_id,name,alt_name,priority from
portal.rubrics");
^
 error
must be
my $sth_rubrics = my_prepare(\$dbh,"select
level,rubric_id,parent_id,type_id,name,alt_name,priority from
portal.rubrics");
)
when I request rubrics.shtml I got a error above, but _all_ other scripts
works correct, until I request 778 port, all scripts are mixed, and
index.shtml returns error of rubrics.shtml and rubrics.shtml returns output
of divisions.shtml and etc.
And other (not shtml, driven by Apache::ASP) files returns correct.


 I think that there is some work to do on use strict error
 handling, but when in doubt, try stopping and then starting
 apache.

Stopping and starting solves this problem fine :) But how about other
solution...



 -- Joshua
 _
 Joshua Chamas Chamas Enterprises Inc.
 NodeWorks  free web link monitoring Huntington Beach, CA  USA
 http://www.nodeworks.com1-714-625-4051




RESOLVED Re: Apache::ASP - I think bug...

1999-12-09 Thread Joshua Chamas

ModPerl list,

It looks like the problem here was that BeerBong had
the same subroutine name defined in multiple scripts,
and since by default all Apache::ASP are compiled into
the same package namespace, one script would call another's
subroutine, whichever was most recently compiled.

If you want to define the same sub name in different scripts,
you need to set the UniquePackages config, so that each 
script will be compiled in its own namespace.  Better I think
to have one common subroutine name defined in global.asa,
or an include that keys off the script filename in $0 or 
File::Basename::basename($0) to determine its modified behavior.

This problem was made harder to figure out because "use strict"
errors work oddly under Apache::ASP to say the least mostly
likely requiring that you restart the dev web server after
getting a "use strict" compile error.

"use strict" errors used to go directly to the apache error log,
but I have trapped them so they will show up in the Apache::ASP
debug output (in my dev version of .18), to HTML if you have 
debug set to 2 or -2, but this is only the first time the compile 
is tried. I'm still trying to get scripts to try to recompile 
after the first use strict error without success.

Anyone have any pointers here on "use strict" compilation errors?
BTW, I found you can trap their output by overriding $SIG{__WARN__}

--Joshua

_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks  free web link monitoring   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051

BeerBong wrote:
 
 Hello Joshua!
 
 I think, I catch new bug of Apache::ASP again, although may be Apache::ASP
 is innocent in this case.
 
 I have 2 Apache servers - simple/proxy and mod_perl and secured virtual site
 of management big Samara portal.
 
 Secured on simple Apache.
 
 
 
 Macro auth_macro $realm $group
 IfDefine simple
 Directory /usr/web/$realm/data/
 AuthType Basic
 AuthName $realm
 AuthUserFile /usr/web/users_file
 AuthGroupFile /usr/web/groups_file
 require group $group
 /Directory
 /IfDefine
 /Macro
 
 
 
 This site is located at http://195.128.133.23:777 - here listen simple
 Apache, mod_perl Apache listen on http://195.128.133.23:778 address and I
 don't want that anyone can acces mod_perl Apache from outside the server
 
 Therefore, I have following handler.
 
 
 
 sub My::ProxyRemoteAddr ($)
 {
 my $r = shift;
 
 # we'll only look at the X-Forwarded-For header if the requests
 # comes from our proxy at localhost
 return FORBIDDEN unless ($r-connection-remote_ip =~ /^195.128.133/);
 
 if (my ($ip) = $r-header_in('X-Forwarded-For') =~ /([^,\s]+)$/)
 {
$r-connection-remote_ip($ip);
 }
 
 return OK;
 }
 
 
 
 All worked just pretty fine until I try, for fun, connect to mod_perl
 directly...
 
 http://195.128.133.23:778/
 
 As I await - I got
 
 
 
 Forbidden
 You don't have permission to access / on this server.
 
 
 
 Apache/1.3.9 Server at www.samara.ru-editor Port 778
 
 
 
 Huh! It's cool! But...
 After it I return to 777 port and request
 http://195.128.133.23:777/index.shtml
 and got a error:
 
 
 
 Errors Output
 
  Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
 while "strict refs" in use at (eval 13) line 14.
 , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142
 
 Debug Output
 
 
 After some refreshes - I got another output, which is not done by
 index.shtml!
 As you can see in debug output 'Last 100 Bytes of Buffered Output' is not
 present in 'ASP to Perl Program' !
 Because 'Last 100 bytes' - code of another script - divisions.shtml ! And
 the same thing happens with all other scripts.
 divisions.shtml shows code of rubrics.shtml and etc.
 
 What you can say ?
 --
 Sergey Polyakov (BeerBong)
 Chief of Web Lab (http://www.mustdie.ru/~beerbong)



Apache::ASP - I think bug...

1999-12-08 Thread BeerBong

Hello Joshua!

I think, I catch new bug of Apache::ASP again, although may be Apache::ASP
is innocent in this case.

I have 2 Apache servers - simple/proxy and mod_perl and secured virtual site
of management big Samara portal.

Secured on simple Apache.



Macro auth_macro $realm $group
IfDefine simple
Directory /usr/web/$realm/data/
AuthType Basic
AuthName $realm
AuthUserFile /usr/web/users_file
AuthGroupFile /usr/web/groups_file
require group $group
/Directory
/IfDefine
/Macro




This site is located at http://195.128.133.23:777 - here listen simple
Apache, mod_perl Apache listen on http://195.128.133.23:778 address and I
don't want that anyone can acces mod_perl Apache from outside the server

Therefore, I have following handler.



sub My::ProxyRemoteAddr ($)
{
my $r = shift;

# we'll only look at the X-Forwarded-For header if the requests
# comes from our proxy at localhost
return FORBIDDEN unless ($r-connection-remote_ip =~ /^195.128.133/);

if (my ($ip) = $r-header_in('X-Forwarded-For') =~ /([^,\s]+)$/)
{
   $r-connection-remote_ip($ip);
}

return OK;
}



All worked just pretty fine until I try, for fun, connect to mod_perl
directly...

http://195.128.133.23:778/

As I await - I got



Forbidden
You don't have permission to access / on this server.




Apache/1.3.9 Server at www.samara.ru-editor Port 778



Huh! It's cool! But...
After it I return to 777 port and request
http://195.128.133.23:777/index.shtml
and got a error:



Errors Output

 Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
while "strict refs" in use at (eval 13) line 14.
, /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142

Debug Output

 STARTING ASP HANDLER (v0.17) for file
/usr/web/www.samara.ru-editor/data/index.shtml
 GlobalASA package
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa
 ASP object created - GlobalASA: Apache::ASP::GlobalASA=HASH(0x8700d08);
Request: Apache::ASP::Request=HASH(0x870443c); Response:
Apache::ASP::Response=HASH(0x876b0b0); Server:
Apache::ASP::Server=HASH(0x8705c0c); app_state: 1; basename: index.shtml;
buffering_on: 1; cgi_headers: 0; clean: 0; compile_includes: 1; dbg: 2;
debugs_output: ARRAY(0x876b134); errs: 0; filename:
/usr/web/www.samara.ru-editor/data/index.shtml; global:
/usr/web/www.samara.ru-editor/global; global_package: ; id:
_usr_web_www_samara_ru_editor_data_index_shtmlxDYN; includes_dir:
/usr/web/inc; init_packages: ARRAY(0x83bed14); mail_alert_to: ;
mail_errors_to: ; mtime: 944649459; no_cache: ; no_session: 0; no_state: 1;
package:
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa;
pod_comments: 1; r: Apache=SCALAR(0x8634908); stat_inc: ; stat_inc_match: ;
unique_packages: 0;
 executing _usr_web_www_samara_ru_editor_data_index_shtmlxDYN
 executing
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_www_samara_ru_editor_global_portal_inc
 executing
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_inc_dbi_inc
 Can't use string ("select level,rubric_id,parent_id") as a SCALAR ref
while "strict refs" in use at (eval 13) line 14.
, /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1142

Last 100 Bytes of Buffered Output

= 'Management site of  www.samara.ru | Rubrics';
 // --
 /script
/head
body bgcolor=#9D


ASP to Perl Program

  1: package
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa; ;;
no strict; ;; use vars qw($Application $Session $Response $Server $Request);
;; sub
Apache::ASP::Compiles::_usr_web_www_samara_ru_editor_global_global_asa::_usr
_web_www_samara_ru_editor_data_index_shtmlxDYN {  ;;  return(1) unless
$_[0];  ;;
$Response-Include('/usr/web/www.samara.ru-editor/global/portal.inc', );
$Response-Write('
  2: ');
  3:
  4: sub main_page {
  5:   my $err = shift;
  6:
  7:   header ("Login - Password");
  8:   info_report ($err);
  9:
 10: $Response-Write('
 11:
 12: strongManagement site of  a
href=http://www.samara.ruwww.samara.ru/a/strong
 13: form action=index.shtml method=post
 14:
 15: table
 16:  tr
 17:   th
 18:Login:
 19:   /td
 20:   td
 21:input type=text name=login tabindex=1
alue="'.( $Request-Cookies("login_name") ).'"input type=submit
value=Enter tabindex=3
 22:   /td
 23:  /tr
 24:  tr