Re: mod_perl doesn't know where perl's installed
Randy Kobes wrote: The specified module could not be found: problem on NT 4 when trying to run Apache/mod_perl as a service. Does it help if you add, in httpd.conf, the directive LoadFile "C:/Path/to/Perl/bin/perl56.dll" before loading mod_perl.so? Hi Randy, I had the same problem with XP: starting Apache 2.0.4x as service fails with the same error. But your tip helped me:-) Thank you again for your good tips. Juergen
Re[2]: redirecting outside the Content handler
Hello Brett Sanger, Friday, November 15, 2002, 1:25:19 AM, you wrote: >> > $r->set_handlers('PerlHandler",\&My::Package::handler); >> >> set_handlers() should work. keep in mind that it's current not >> possible (IIRC) to set_handler() for the current phase. so, for the >> PerlHandler you'd want to do it from someplace else, like your >> PerlAccessHandler or something. BS> Which is ideal for me, since I'm trying to set it in the BS> PerlAccessHandler >> oh, and the syntax doesn't require a coderef - >>$r->set_handlers(PerlHandler => 'My::Package'); >> works too. BS> Each of these: $r->>set_handlers(PerlHandler => 'My::Package'); $r->>set_handlers(PerlHandler => 'My::Package::handler'); $r->>set_handlers(PerlHandler => \&My::Package); $r->>set_handlers(PerlHandler => \&My::Package::handler); BS> give me: BS> [error] Can't set_handler with that value BS> Any ideas? BS> (I've also tried the same variations on $r->>set_handlers(PerlHandler => BS> 'Apache::ROOT::path::to::myscript_23pl'); BS> to try and convince it to load my Apache::Registry scripts, with the BS> same results BS> ) from the 'perldoc Apache' $r->set_handlers( $hook, [\&handler, ... ] ) Sets the list if handlers to be called for $hook. $hook is a string representing the phase to handle. The list of handlers is an anonymous array of code references to the handlers to install for this request phase. The special list [ \&OK ] can be used to disable a particular phase. $r->set_handlers( PerlLogHandler => [ \&myhandler1, \&myhandler2 ] ); $r->set_handlers( PerlAuthenHandler => [ \&OK ] ); See ? It await for arrayref not scalar or coderef :(, and the sub name too. -- WBR, Mike P. Mikhailov mailto:mike@;sibtel.ru Moving the mouse won't get you into trouble... Clicking it might
Re: File Upload Questions
Dennis Daupert <[EMAIL PROTECTED]> wrote: > I have gotten file upload working using Apache::Request for > text files. But binary files seem to have other ideas :-) > > For example, uploading a word doc, I get a success message, > but when I retrieve the doc after uploading it, and try to open it in > Word 2000, I get the popup error message: > > "The document name or path is not valid... etc" [...] > > In case I have done something silly in my code, [...] you may have done one silly thing :-) > my $fh = $upload->fh; > my @file = <$fh>; here you slurp the lines of the text file into the @file array > print WRITEFILE "@file"; and here you put the @file array into double-quotes. normal string interpolation of an array is to join together the elements of the array, separated by a *space*. this is not what you wanted to do. for instance, this code: @a=('a','b','c'); print "@a"; prints: "a b c" instead of "abc" while: @a=('a','b','c'); print @a; prints: "abc" so you should try: print WRITEFILE @file; # without the quotes instead and see if that works. hth, -dave
Re: File Upload Questions
On Thu, 14 Nov 2002, Dennis Daupert wrote: > I have gotten file upload working using Apache::Request for > text files. But binary files seem to have other ideas :-) > > For example, uploading a word doc, I get a success message, > but when I retrieve the doc after uploading it, and try to open it in > Word 2000, I get the popup error message: > > "The document name or path is not valid... etc" > > Do I need to do anything to detect the content type of the file and > set binary versus ascii transfers? The man page for Apache::Request > talks about type, but not how to set the transfer. > > In case I have done something silly in my code, here is a section in which > I untaint the filename, and also remove the leading c:\path\to\file info > (for windows uploads) or similar /path/to/file for unix uploads: [ .. ] > And then: > my $fh = $upload->fh; > my @file = <$fh>; > open ( WRITEFILE, ">$data{'write_dir'}/$data > {'up_filename'}" ) or die "couldn't open $data{'up_filename'} for writing: > $! \n"; > print WRITEFILE "@file"; > close (WRITEFILE); For binary docs, would a binmode WRITEFILE; before the print statement help? -- best regards, randy kobes
Re: URI escaping question
It looks like the default character class used by URI::Escape::uri_escape changed in version 1.16 to be exactly the same as the one I suggested. Older versions didn't escape the reserved characters. - Kyle - Original Message - From: "Kyle Oppenheim" <[EMAIL PROTECTED]> To: "modperl List" <[EMAIL PROTECTED]> Sent: Thursday, November 14, 2002 4:10 PM Subject: Re: URI escaping question > According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) the reserved > characters in the query component of a URI are ";", "/", "?", ":", "@","&", > "=", "+", ",", and "$". > Apache::Util->escape_uri() does not escape ":", "@", "&", "=", "+", ",", or > "$". > > Something like the following should work: > > use URI::Escape qw(uri_escape); > > sub uri_escape_query_value { > my $character_class = '^A-Za-z0-9\-_.!~*\'()'; > uri_escape($_[0], $character_class); > } > > - Kyle > > - Original Message - > From: "Ray Zimmerman" <[EMAIL PROTECTED]> > To: "modperl List" <[EMAIL PROTECTED]> > Cc: "Raj Chandran" <[EMAIL PROTECTED]> > Sent: Thursday, November 14, 2002 12:25 PM > Subject: URI escaping question > > > > Oops ... finger slipped before I was done typing ... > > > > Suppose I have a hash of string values that I want to include in the > > query string of a redirect URL. What is the accepted way of escaping > > the values to be sure that they come through intact? > > > > Specifically, it seems that Apache::Util->escape_uri() is not > > escaping '=' and '&' so if one of the values in the hash is a URI > > with a query string it messes things up. > > > > -- > > Ray Zimmerman / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall > >Sr Research / phone: (607) 255-9645 / Cornell University > > Associate / FAX: (815) 377-3932 / Ithaca, NY 14853 > > > >
Re: How can I tell if a request was proxy-passed form an SSLserver?
John Siracusa writes: > and that does the trick. The full code for the module is at the end of this > message. But I still think this is an ugly hack, and I'd like to be able to > do this using "standard" apache modules or config parameters... Our hack is to forward 443 to port 81 on the middle tier: ... ProxyVia on ... RewriteRule ^(.*) http://middle.tier.host:81$1 [proxy] We set a value (is_secure => 1) on our internal request object when it is initialized if the incoming port is 81. We also set remote_ip with: $r->connection->remote_ip($1) if ($r->header_in('x-forwarded-for') || '') =~ /((?:\d+\.){3}\d+)/; This makes the log entries useful. There might be an easier way to do this. Rob
Re: How can I tell if a request was proxy-passed form an SSLserver?
On 11/14/02 5:48 PM, Marcin Kasperski wrote: > What about the simple manual solution: frontend server proxies > /some/url to /http/some/url on backend for HTTP and to /https/some/url > on backend for HTTPS. Or something similar... On 11/14/02 6:56 PM, Carolyn Hicks wrote: > If you can proxy-pass HTTP and HTTPS requests to different ports on the > backend server, you just need to check which port the backend is listening > on to tell if the request came through SSL or not. Both of those would work, but aren't quite what I'm looking for. IMO, there should be some way to do what I ended up doing with my little C apache module, namely to add X-Whatever header(s) to a proxy-passed request. I'd imagine something like: Proxy(Add|Set|Unset)Header Maybe apache 2.0 has something like that, but I'm still using 1.3.x for now... -John
Re: Server Parsed .shtml files...
Thanks Geoff, you are an absolute genius. I wrote a little PerlFixupHandler to solve the issue as that was most appropriate for the configuration i had. thanks again, simran. On Fri, 2002-11-15 at 00:57, Geoffrey Young wrote: > > > simran wrote: > > Hi All, > > > > I have a auth protected area for the apache server: > > > > Aka, the location /auth is password protected by Perl*Handlers and > > usually i only write other PerlHandlers that do things under that > > location. > > > > However, i need to put a .shtml file into that diretory (it is also a > > normal directory under the document root). > > > > Putting .html files there is no problem, they display fine, however, > > .shtml files do not get parsed when in that directory (they work fine > > from everywhere else on the server). I assume this is because under that > > directory, SetHandler is set to perl-script and not server-parsed? > > yes, exactly. SetHandler gets the highest priority, and overrides > things such as AddHandler you may have set elsewhere. > > > > Is there a way i can use the "Files" directive (or any other way) to get > > the server to parse .shtml files in that directory? > > won't help you once you're in the covered by > SetHandler (at least I don't think so, but it's early). I'd probably > write a PerlFixupHandler to undo the SetHandler for .shtml files or > something if you really needed to override your global SetHandler for > a given . it's generally as simple as > > $r->handler('server-parsed') if $r->filename =~ m!\.shtml$!; > > but you could probably just as easily remove the SetHandler > perl-script in that directory and exchange it for the proper set of > AddHandler directives. > > HTH > > --Geoff > > > >
Re: URI escaping question
According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) the reserved characters in the query component of a URI are ";", "/", "?", ":", "@","&", "=", "+", ",", and "$". Apache::Util->escape_uri() does not escape ":", "@", "&", "=", "+", ",", or "$". Something like the following should work: use URI::Escape qw(uri_escape); sub uri_escape_query_value { my $character_class = '^A-Za-z0-9\-_.!~*\'()'; uri_escape($_[0], $character_class); } - Kyle - Original Message - From: "Ray Zimmerman" <[EMAIL PROTECTED]> To: "modperl List" <[EMAIL PROTECTED]> Cc: "Raj Chandran" <[EMAIL PROTECTED]> Sent: Thursday, November 14, 2002 12:25 PM Subject: URI escaping question > Oops ... finger slipped before I was done typing ... > > Suppose I have a hash of string values that I want to include in the > query string of a redirect URL. What is the accepted way of escaping > the values to be sure that they come through intact? > > Specifically, it seems that Apache::Util->escape_uri() is not > escaping '=' and '&' so if one of the values in the hash is a URI > with a query string it messes things up. > > -- > Ray Zimmerman / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall >Sr Research / phone: (607) 255-9645 / Cornell University > Associate / FAX: (815) 377-3932 / Ithaca, NY 14853 >
Re: How can I tell if a request was proxy-passed form an SSL server?
On Thu, Nov 14, 2002 at 12:45:52PM -0500, John Siracusa wrote: > Assume I have a front-end (non-mod_perl) proxy server that supports both > HTTP and HTTPS. I want to know, from within my Perl code on the back-end > (HTTP-only) mod_perl server, if the current request was ProxyPass-ed to me > based on an original HTTP or HTTPS request from the user. > > There doesn't appear to be a way to add headers to the proxy request on a > per-virtual-host basis using mod_proxy, and I don't see any other headers > that I can use to distinguish between an HTTP or HTTPS front-end server. > Any ideas? If you can proxy-pass HTTP and HTTPS requests to different ports on the backend server, you just need to check which port the backend is listening on to tell if the request came through SSL or not. http://perl.apache.org/docs/1.0/guide/config.html#Knowing_the_proxy_pass_ed_Connection_Type -carolyn
Hellp! mod_perl worked fine then added modssl and now apache won't start
Hi all, I am still new to all of this. I had Apache 1.3.22 with mod_perl included and the Authenitcation hook enabled. Everything was fine. Then I imstalled my OpenSSL and generated my key, got my server certificate from my csr etc fine. The certificate has been verified. I then with mod_ssl-2.8.5-1.3.22 did ./configure \ --with-apache=/web/server/apache/1.3.22-source \ --with-ssl=/web/server/OpenSSL/0.9.6g \ --with-crt=/web/server/OpenSSL/0.9.6g/bin/serverPEM.crt \ --with-key=/web/server/OpenSSL/0.9.6g/bin/server.key \ --prefix=/=/web/server/apache/1.3.22 This went fine. make went fine. Because I used with-crt/with-key I skipped make certificate (yes serverPEM.crt and server.key are the real certificate and private key) make install goes fine. I stop Apache fine. Once start I get the following error Syntax error on line 1008 of /web/server/apache/1.3.22/conf/httpd.conf: Invalid command 'PerlModule', perhaps mis-spelled or defined by a module not included in the server configuration /web/server/apache/1.3.22/bin/apachectl start: httpd could not be started I remove the following lines from my httpd.conf file because I was only using them once before to ensure my mod_perl hooks were enabled. Now starting apache I get: /web/server/apache/1.3.22/bin/apachectl start: httpd could not be started Here is the messages in the error log for the last attempt at starting: [Thu Nov 14 16:35:31 2002] [error] mod_ssl: Init: Failed to generate temporary 512 bit RSA private key (OpenSSL library error follows) [Thu Nov 14 16:35:31 2002] [error] OpenSSL: error:24064064:random number generator:SSLEAY_RAND_BYTES:PRNG not seeded [Thu Nov 14 16:35:31 2002] [error] OpenSSL: error:04069003:rsa routines:RSA_generate_key:BN lib The machine has a /dev/random . Greping for Random out of my Apache conf directory I get: httpd.conf.default:# Pseudo Random Number Generator (PRNG): httpd.conf.default:SSLRandomSeed startup builtin httpd.conf.default:SSLRandomSeed connect builtin httpd.conf.default:#SSLRandomSeed startup file:/dev/random 512 httpd.conf.default:#SSLRandomSeed startup file:/dev/urandom 512 httpd.conf.default:#SSLRandomSeed connect file:/dev/random 512 httpd.conf.default:#SSLRandomSeed connect file:/dev/urandom 512 Do I need to add one of these to my httpd.conf since that is what get used? But which one? Thanks. Jem
Re: How can I tell if a request was proxy-passed form an SSL server?
John Siracusa <[EMAIL PROTECTED]> writes: > Assume I have a front-end (non-mod_perl) proxy server that supports both > HTTP and HTTPS. I want to know, from within my Perl code on the back-end > (HTTP-only) mod_perl server, if the current request was ProxyPass-ed to me > based on an original HTTP or HTTPS request from the user. > > There doesn't appear to be a way to add headers to the proxy request on a > per-virtual-host basis using mod_proxy, and I don't see any other headers > that I can use to distinguish between an HTTP or HTTPS front-end server. > Any ideas? What about the simple manual solution: frontend server proxies /some/url to /http/some/url on backend for HTTP and to /https/some/url on backend for HTTPS. Or something similar... -- ( Marcin Kasperski | Communication takes place between people, documents ) ( http://www.mk.w.pl |are secondary. (Booch) ) () ( Moje prywatne strony: http://www.kasperski.prv.pl )
Re: weird cookie behavior
valerian wrote: I'm experiencing strange behavior with cookies when my scripts are accessed in mod_perl (using Apache::Registry). Everything works fine so long as my browser is configured to not go through a proxy (ie, in Netscape 4.77, "directly connected to the Internet" option is selected). When I configure it to use a custom proxy (eg, Junkbuster running on my LAN gateway), my cookies no longer work, but I can still browse the web fine. I would not rule out the junkbuster proxy just yet. To get at the root of the problem, you will need to see the HTTP headers as they are output directly from your program, with and without the proxy. You can use lwp-request for this like: lwp-request -ed http://URL/PATH lwp-request -ed -p PROXY http://URL/PATH and see what HTTP headers come back. If the headers change, then maybe the junkbuster proxy is munging something up or dropping headers. It may be that there is some header special to mod_perl that is messing up junkbuster for example so that you do not see the problem in CGI mode. There is also a chance that junkbuster is adding some header, only for the mod_perl output that simply messes up netscape. Either way, seeing the headers themselves should help get to the root of it. If its the former scenario, I would take the problem first to the junkbuster developers. Regards, Josh Josh Chamas, Founder phone:925-552-0128 Chamas Enterprises Inc.http://www.chamas.com NodeWorks Link Checkinghttp://www.nodeworks.com
File Upload Questions
I have gotten file upload working using Apache::Request for text files. But binary files seem to have other ideas :-) For example, uploading a word doc, I get a success message, but when I retrieve the doc after uploading it, and try to open it in Word 2000, I get the popup error message: "The document name or path is not valid... etc" Do I need to do anything to detect the content type of the file and set binary versus ascii transfers? The man page for Apache::Request talks about type, but not how to set the transfer. In case I have done something silly in my code, here is a section in which I untaint the filename, and also remove the leading c:\path\to\file info (for windows uploads) or similar /path/to/file for unix uploads: # now let's untaint the filename itself if ($data{'up_filename'} =~ /^([-\@\/\w\:\\.]+)$/) { $data{'up_filename'} = $1; my $cleanfile = $data{'up_filename'}; $cleanfile = $1; # $cleanfile now untainted $cleanfile =~ s#\.\.##g; $cleanfile =~ s[//][/]g; # take out windows backslashes if ($cleanfile =~ /\\/) { my @parts = split ( /\\/, $cleanfile ); $cleanfile = pop @parts; } # take out unix forward slashes if ($cleanfile =~ /\//) { my @parts = split ( /\//, $cleanfile ); $cleanfile = pop @parts; } $data{'up_filename'} = $cleanfile; } And then: my $fh = $upload->fh; my @file = <$fh>; open ( WRITEFILE, ">$data{'write_dir'}/$data {'up_filename'}" ) or die "couldn't open $data{'up_filename'} for writing: $! \n"; print WRITEFILE "@file"; close (WRITEFILE); Any insight greatly appreciated. /dennis --- Office phone: 817-762-8304 --- "Great leaders never tell people how to do their jobs. Great leaders tell people what to do and establish a framework within which it must be done. Then they let people on the front lines, who know best, figure out how to get it done." ~ General H. Norman Schwarzkopf
Re: odd headers with Apache::add_version_component()
Even if I can get this to work through certain config tweaks, I will not add this to Apache::ASP as I would need this to be correct for all user configs, not just mine. I do not want to preempt the Apache/... header! Thanks for the follow up. Maybe I'll revist this in MP2. sure. it's really a shame about this one, since it's a nice feature. maybe somebody will revisit it in mod_perl core one day. you know, you make a conscious decision to write about how things are documented/expected to behave, even when you know there are bugs, and then... :) --Geoff
Re: odd headers with Apache::add_version_component()
Geoffrey Young wrote: from what I remember, this method is very strange - it depends lots on how your server is set up. for instance, whether you're using DSO (which breaks down the interpreter on restarts) and/or whether you have PerlFreshRestart On. both of these behaviors seem to affect the order of the tokens. I am not using DSO, but it is enabled. When I set PerlFreshRestart On, I do get the header in the right place, but its also still in the wrong place! Server: Apache::ASP/2.49 Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27 Perl/v5.8.0 Apache::ASP/2.49 mod_ssl/2.8.11 OpenSSL/0.9.6g At least we are a step closer. Even if I can get this to work through certain config tweaks, I will not add this to Apache::ASP as I would need this to be correct for all user configs, not just mine. I do not want to preempt the Apache/... header! Thanks for the follow up. Maybe I'll revist this in MP2. Regards, Josh Josh Chamas, Founder phone:925-552-0128 Chamas Enterprises Inc.http://www.chamas.com NodeWorks Link Checkinghttp://www.nodeworks.com
Re: redirecting outside the Content handler
Each of these: $r->set_handlers(PerlHandler => 'My::Package'); $r->set_handlers(PerlHandler => 'My::Package::handler'); $r->set_handlers(PerlHandler => \&My::Package); $r->set_handlers(PerlHandler => \&My::Package::handler); give me: [error] Can't set_handler with that value Any ideas? yeah, sorry. push_handlers() takes a scalar, set_handlers() takes an array reference: $r->set_handlers(PerlHandler => ['My::Package']); $r->set_handlers(PerlHandler => [\&My::Package]); etc. --Geoff
Re: problem with session ids
Minas wrote: Recently I installed the Apache::Session module on my server in order to give a kind of identity to my e-shop visitors, seems to work but generates different session ids when I reload the bellow test cgi. What can I do in order to have my visitor the same session id, up to close his web browser. I've run into problems recently with sessions being re-created, and discovered that the first cookie was being created in a sub-directory of my site (e.g. foo.com/a/b.xsp), but a new session was being created when other pages were loaded elsewhere in my site (e.g. foo.com/c/d.xsp). When I created the cookies, I was accepting all the defaults, so the cookie was being limited to the sub-directory of my site. My fix for this was to explicitly set the PATH variable of my cookie to be set to "/". This might be your problem. -- -man Michael A Nachbaur The best way to predict the Future is to invent it. PGP Public Key at http://www.nachbaur.com/pgpkey.asc PGP Key fingerprint = 83DC 7C3A 3084 6A21 9A3F 801E D974 AFB4 BFD7 2B6F
Re: redirecting outside the Content handler
> > $r->set_handlers('PerlHandler",\&My::Package::handler); > > set_handlers() should work. keep in mind that it's current not > possible (IIRC) to set_handler() for the current phase. so, for the > PerlHandler you'd want to do it from someplace else, like your > PerlAccessHandler or something. Which is ideal for me, since I'm trying to set it in the PerlAccessHandler > oh, and the syntax doesn't require a coderef - >$r->set_handlers(PerlHandler => 'My::Package'); > works too. Each of these: $r->set_handlers(PerlHandler => 'My::Package'); $r->set_handlers(PerlHandler => 'My::Package::handler'); $r->set_handlers(PerlHandler => \&My::Package); $r->set_handlers(PerlHandler => \&My::Package::handler); give me: [error] Can't set_handler with that value Any ideas? (I've also tried the same variations on $r->set_handlers(PerlHandler => 'Apache::ROOT::path::to::myscript_23pl'); to try and convince it to load my Apache::Registry scripts, with the same results )
URI escaping question
Oops ... finger slipped before I was done typing ... Suppose I have a hash of string values that I want to include in the query string of a redirect URL. What is the accepted way of escaping the values to be sure that they come through intact? Specifically, it seems that Apache::Util->escape_uri() is not escaping '=' and '&' so if one of the values in the hash is a URI with a query string it messes things up. -- Ray Zimmerman / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall Sr Research / phone: (607) 255-9645 / Cornell University Associate / FAX: (815) 377-3932 / Ithaca, NY 14853
URI escaping question
Suppose I have a hash of string values that I want to include in the query string of a redirect URL. What is the accepted way of escaping the values to be sure that they come through intact? Specifically, it seems that Apache::Util->escape_uri() -- Ray Zimmerman / e-mail: [EMAIL PROTECTED] / 428-B Phillips Hall Sr Research / phone: (607) 255-9645 / Cornell University Associate / FAX: (815) 377-3932 / Ithaca, NY 14853
Re: odd headers with Apache::add_version_component()
Josh Chamas wrote: Hey, I'm looking to get Apache::ASP to insert itself into the module Server tokens with the add_version_component() API, so I call it like this: package Apache::ASP ... &Apache::add_version_component("Apache::ASP/$VERSION"); ... 1; but then it becomes the first header on the list!, and I do not want it to look like it is the actual web server itself... from what I remember, this method is very strange - it depends lots on how your server is set up. for instance, whether you're using DSO (which breaks down the interpreter on restarts) and/or whether you have PerlFreshRestart On. both of these behaviors seem to affect the order of the tokens. the reason I know this is a few private emails between doug and I after this: http://marc.theaimsgroup.com/?l=apache-modperl-cvs&m=99453039711626&w=2 the box I wrote the book on worked just fine, placing the token at the end like we illustrate. that one happened to be static without PerlFreshRestart on linux. go figure. Server: Apache::ASP/2.49 Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27 Perl/v5.8.0 mod_ssl/2.8.11 OpenSSL/0.9.6g So, how can I use this method correctly, so that Apache::ASP ends up near the end of the server tokens? BTW, I dug up this method from the mod_perl Cookbook very good examples, http://www.modperlcookbook.org/ thanks :) HTH --Geoff
Re: How can I tell if a request was proxy-passed form an SSLserver?
On 11/14/02 2:39 PM, Randy Kobes wrote: > On Thu, 14 Nov 2002, John Siracusa wrote: >> I tried turning on ProxyVia, but all I got was the HTTP >> protocol version ("1.1") and the host ("www.foo.com"), but no >> scheme string (e.g. "http://"; or "https://";) > > Were these from requests you know were made using https? Yep, but I still just get the version number. > My reading of the Via header was that the protocol name is optional > only if it is HTTP, implying that if it's not given, you can > assume it's HTTP. That doesn't appear to be the case with mod_proxy in apache 1.3.27. I ended up having to make a trivial C apache module (using the old mod_proxy_add_forward.c as a basis) to set my own header. Of course, first I had to find out if the request is SSL. I figured I'd look for the env var that mod_ssl sets: https = getenv("HTTPS"); if(https) ap_table_set(r->headers_in, "X-Forwarded-For-SSL", "yes"); But that didn't work. (I also tried many of the SSL_* env vars.) So then I tried looking where mod_ssl actually puts its HTTPS env var, in the subprocess_env structure: table *e = r->subprocess_env; if(ap_table_get(e, "HTTPS")) ap_table_set(r->headers_in, "X-Forwarded-For-SSL", "yes"); But that didn't work either. I forced my trivial module to the end of the module chain just to make sure mod_ssl got a chance to set its var(s) first, but that didn't help. Finally, I found something that did work: method = ap_ctx_get(r->ctx, "ap::http::method"); if(method) ap_table_set(r->headers_in, "X-Forwarded-For-Method", method); Apparently, this is only set by mod_ssl if method is "https". If it is HTTP, this is not set at all. Anyway, I just check for this on the mod_perl side with: if($r->header_in('X-Forwarded-For-Method') eq 'https') { ... } and that does the trick. The full code for the module is at the end of this message. But I still think this is an ugly hack, and I'd like to be able to do this using "standard" apache modules or config parameters... -John --- #include "httpd.h" #include "http_config.h" #include "http_core.h" module MODULE_VAR_EXPORT proxy_add_ssl_module; static int add_ssl_header(request_rec *r) { const char *method; if(r->proxyreq == PROXY_PASS) { method = ap_ctx_get(r->ctx, "ap::http::method"); if(method) ap_table_set(r->headers_in, "X-Forwarded-For-Method", method); return OK; } return DECLINED; } module MODULE_VAR_EXPORT proxy_add_ssl_module = { STANDARD_MODULE_STUFF, NULL, /* initializer */ NULL, /* dir config creater */ NULL, /* dir merger --- default is to override */ NULL, /* server config */ NULL, /* merge server configs */ NULL, /* command table */ NULL, /* handlers */ NULL, /* filename translation */ NULL, /* check_user_id */ NULL, /* check auth */ NULL, /* check access */ NULL, /* type_checker */ add_ssl_header, /* fixups */ NULL, /* logger */ NULL, /* header parser */ NULL, /* child_init */ NULL, /* child_exit */ NULL/* post read-request */ };
odd headers with Apache::add_version_component()
Hey, I'm looking to get Apache::ASP to insert itself into the module Server tokens with the add_version_component() API, so I call it like this: package Apache::ASP ... &Apache::add_version_component("Apache::ASP/$VERSION"); ... 1; but then it becomes the first header on the list!, and I do not want it to look like it is the actual web server itself... Server: Apache::ASP/2.49 Apache/1.3.27 (Unix) PHP/4.2.3 mod_perl/1.27 Perl/v5.8.0 mod_ssl/2.8.11 OpenSSL/0.9.6g So, how can I use this method correctly, so that Apache::ASP ends up near the end of the server tokens? BTW, I dug up this method from the mod_perl Cookbook very good examples, http://www.modperlcookbook.org/ Thanks, Josh Josh Chamas, Founder phone:925-552-0128 Chamas Enterprises Inc.http://www.chamas.com NodeWorks Link Checkinghttp://www.nodeworks.com
Re: How can I tell if a request was proxy-passed form an SSL server?
On Thu, 14 Nov 2002, John Siracusa wrote: > On 11/14/02 2:12 PM, Randy Kobes wrote: > > > > If your front-end proxy server has 'ProxyVia on' enabled, a Via > > header would get sent. According to rfc2068, the protocol name > > should, and port may, be supplied in this header if these aren't > > the defaults - would this be enough to enable your mod_perl > > server to distinguish between an HTTP or HTTPS request? > > I tried turning on ProxyVia, but all I got was the HTTP > protocol version ("1.1") and the host ("www.foo.com"), but no > scheme string (e.g. "http://"; or "https://";) Were these from requests you know were made using https? My reading of the Via header was that the protocol name is optional only if it is HTTP, implying that if it's not given, you can assume it's HTTP. Perhaps less useful, if the port is not given, it may be assumed that the default port is used. -- best regards, randy
Re: How can I tell if a request was proxy-passed form an SSLserver?
On 11/14/02 2:12 PM, Randy Kobes wrote: > On Thu, 14 Nov 2002, John Siracusa wrote: >> Assume I have a front-end (non-mod_perl) proxy server that >> supports both HTTP and HTTPS. I want to know, from within my >> Perl code on the back-end (HTTP-only) mod_perl server, if the >> current request was ProxyPass-ed to me based on an original >> HTTP or HTTPS request from the user. >> >> There doesn't appear to be a way to add headers to the proxy >> request on a per-virtual-host basis using mod_proxy, and I >> don't see any other headers that I can use to distinguish >> between an HTTP or HTTPS front-end server. Any ideas? > > If your front-end proxy server has 'ProxyVia on' enabled, a Via > header would get sent. According to rfc2068, the protocol name > should, and port may, be supplied in this header if these aren't > the defaults - would this be enough to enable your mod_perl > server to distinguish between an HTTP or HTTPS request? I tried turning on ProxyVia, but all I got was the HTTP protocol version ("1.1") and the host ("www.foo.com"), but no scheme string (e.g. "http://"; or "https://";) -John
Re: How can I tell if a request was proxy-passed form an SSL server?
On Thu, 14 Nov 2002, John Siracusa wrote: > Assume I have a front-end (non-mod_perl) proxy server that > supports both HTTP and HTTPS. I want to know, from within my > Perl code on the back-end (HTTP-only) mod_perl server, if the > current request was ProxyPass-ed to me based on an original > HTTP or HTTPS request from the user. > > There doesn't appear to be a way to add headers to the proxy > request on a per-virtual-host basis using mod_proxy, and I > don't see any other headers that I can use to distinguish > between an HTTP or HTTPS front-end server. Any ideas? If your front-end proxy server has 'ProxyVia on' enabled, a Via header would get sent. According to rfc2068, the protocol name should, and port may, be supplied in this header if these aren't the defaults - would this be enough to enable your mod_perl server to distinguish between an HTTP or HTTPS request? -- best regards, randy kobes
RE: mod_perl doesn't know where perl's installed
> > Has anyone solved this problem? Is there anyway to tell > mod_perl where perl > > is without using the PATH variable? > > Is it a problem just as a service, or does the same thing > occur running Apache from the console? > > Does it help if you add, in httpd.conf, the directive >LoadFile "C:/Path/to/Perl/bin/perl56.dll" > before loading mod_perl.so? > > -- > best regards, > randy kobes > > The problem occurs only when run as a service. And, yes, the LoadFile directive seems to have solved it. I would have *never* come up with that. Many Thanks! - Scott Scott Scecina In Mind, Inc.
Re: redirecting outside the Content handler
"Narins, Josh" wrote: > > I think I know this one. > > #you might want to do this line, for edification if nothing else > my $list_ref = $r->get_handlers("PerlHandler"); > > $r->set_handlers('PerlHandler",\&My::Package::handler); Excellent! Thanks. One associated question: Is it possible to manipulate things such that I'm calling an Apache::Registry script? I can make a handle to redirect, but I'm sure that isn't necessary. The Eagle book only mentioned direct handlers.
Re: redirecting outside the Content handler
Narins, Josh wrote: I think I know this one. #you might want to do this line, for edification if nothing else my $list_ref = $r->get_handlers("PerlHandler"); $r->set_handlers('PerlHandler",\&My::Package::handler); sorry, I misread when I replied with internal_redirect_handler. set_handlers() should work. keep in mind that it's current not possible (IIRC) to set_handler() for the current phase. so, for the PerlHandler you'd want to do it from someplace else, like your PerlAccessHandler or something. oh, and the syntax doesn't require a coderef - $r->set_handlers(PerlHandler => 'My::Package'); works too. sorry for the confusion. --Geoff -Original Message- From: Brett Sanger [mailto:brs900@;email1.dss.state.va.us] Sent: Thursday, November 14, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: redirecting outside the Content handler I have a few AccessHandlers that I'd like to redirect the user to the correct page to get access if they don't have it. I tried ErrorDocuments, but I have multiple layers of authentication, and ErrorDocuments won't cascade. So I'm looking at switching the ContentHandler. internal_redirect() won't work, since it only works as intended inside the content handler. Can I just override the currently expected ContentHandler? How would I do that? -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
RE: redirecting outside the Content handler
I think I know this one. #you might want to do this line, for edification if nothing else my $list_ref = $r->get_handlers("PerlHandler"); $r->set_handlers('PerlHandler",\&My::Package::handler); -Original Message- From: Brett Sanger [mailto:brs900@;email1.dss.state.va.us] Sent: Thursday, November 14, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: redirecting outside the Content handler I have a few AccessHandlers that I'd like to redirect the user to the correct page to get access if they don't have it. I tried ErrorDocuments, but I have multiple layers of authentication, and ErrorDocuments won't cascade. So I'm looking at switching the ContentHandler. internal_redirect() won't work, since it only works as intended inside the content handler. Can I just override the currently expected ContentHandler? How would I do that? -- This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
Re: redirecting outside the Content handler
Brett Sanger wrote: I have a few AccessHandlers that I'd like to redirect the user to the correct page to get access if they don't have it. I tried ErrorDocuments, but I have multiple layers of authentication, and ErrorDocuments won't cascade. So I'm looking at switching the ContentHandler. internal_redirect() won't work, since it only works as intended inside the content handler. Can I just override the currently expected ContentHandler? How would I do that? $r->internal_redirect_handler() HTH --Geoff
How can I tell if a request was proxy-passed form an SSL server?
Assume I have a front-end (non-mod_perl) proxy server that supports both HTTP and HTTPS. I want to know, from within my Perl code on the back-end (HTTP-only) mod_perl server, if the current request was ProxyPass-ed to me based on an original HTTP or HTTPS request from the user. There doesn't appear to be a way to add headers to the proxy request on a per-virtual-host basis using mod_proxy, and I don't see any other headers that I can use to distinguish between an HTTP or HTTPS front-end server. Any ideas? -John
Re: @INC + use Lib
Pierre Smolarek wrote: I've been having problems with use lib. I read the extract at http://perl.apache.org/docs/1.0/guide/porting.html#_INC_and_mod_perl and realised that you can hardcode @INC via httpd.conf or startup.pl. however, i tried adding PerlSetEnv PERL5LIB to a .htaccess file but that doesn't seem to work!? @INC is hardcoded at the server startup and gets reset after each request. Is there someway to isolate the paths to specific virtualhosts or directories? I tried adding it within a directory command in httpd.conf but it didn't seem to work. Look at: http://perl.apache.org/docs/1.0/guide/config.html#Is_There_a_Way_to_Modify__INC_on_a_Per_Virtual_Host_or_Per_Location_Basis_ http://perl.apache.org/docs/1.0/guide/modules.html#Apache__PerlVINC___Allows_Module_Versioning_in_Location_blocks_and_Virtual_Hosts __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:stas@;stason.org http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Help - SEGFAULTS on 'PerlModule' after version upgrade
Rafiq Ismail (ADMIN) wrote: Ugggh: My software works with the 'original server settings', (apache 1.3.24/mod_perl 1.26) see below(1), under linux. It doesn't work with 'new server settings', (apache 1.3.26 / mod_perl 1.26) see below(2), under freeBSD. Symptoms: With the new build, I get seg faults with 'some' of the PerlModules included through PerlModule in various virtualhosts. Other modules work. These packages all run with strict and do not include any XS besides what may hide under the cover with DBI, Date::Calc and Template. I also have a headache. The packages were happily being included into my old build and there is nothing unusual about them. An strace displays the last couple of lines before a segfault as follows: See, http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems you need to send the gdb backtrace, not the strace's output. FWIW, I've had segfaults on 'use DBI' with mod_perl 2.0/perl 5.8.0, which have gone after I've updated the DBI package. Try to do the same. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:stas@;stason.org http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
redirecting outside the Content handler
I have a few AccessHandlers that I'd like to redirect the user to the correct page to get access if they don't have it. I tried ErrorDocuments, but I have multiple layers of authentication, and ErrorDocuments won't cascade. So I'm looking at switching the ContentHandler. internal_redirect() won't work, since it only works as intended inside the content handler. Can I just override the currently expected ContentHandler? How would I do that?
Re: mod_perl doesn't know where perl's installed
On Thu, 14 Nov 2002, Scott Scecina wrote: > Hi! > > I'm running into the: > > > Syntax error on line 1022 of c:/program files/apache/conf/httpd.conf: > > Cannot load c:/program files/apache/modules/mod_perl.so into server: (126) > The specified module could not be found: > > problem on NT 4 when trying to run Apache/mod_perl as a service. > > (see: http://www.geocrawler.com/archives/3/182/2001/8/50/6508119/) > > I have verified that my Apache/modperl/perl versions match, and that I have > "c:\perl\bin" in the System PATH, however, I suspect that NT doesn't setup > those variables for services? I don't have this problem on Win2k. > > Has anyone solved this problem? Is there anyway to tell mod_perl where perl > is without using the PATH variable? Is it a problem just as a service, or does the same thing occur running Apache from the console? Does it help if you add, in httpd.conf, the directive LoadFile "C:/Path/to/Perl/bin/perl56.dll" before loading mod_perl.so? -- best regards, randy kobes
mod_perl doesn't know where perl's installed
Hi! I'm running into the: > Syntax error on line 1022 of c:/program files/apache/conf/httpd.conf: > Cannot load c:/program files/apache/modules/mod_perl.so into server: (126) The specified module could not be found: problem on NT 4 when trying to run Apache/mod_perl as a service. (see: http://www.geocrawler.com/archives/3/182/2001/8/50/6508119/) I have verified that my Apache/modperl/perl versions match, and that I have "c:\perl\bin" in the System PATH, however, I suspect that NT doesn't setup those variables for services? I don't have this problem on Win2k. Has anyone solved this problem? Is there anyway to tell mod_perl where perl is without using the PATH variable? Any help is GREATLY appreciated! Thanks! - Scott Scott Scecina In Mind, Inc.
Re: Server Parsed .shtml files...
Better choice is add .shtml to server-parsed. See below: # # To use server-parsed HTML files # AddType text/html .shtml .html .htm AddHandler server-parsed .shtml .html .htm Willy simran cc: Subject: Server Parsed .shtml files... 11/14/2002 03:50 AM Hi All, I have a auth protected area for the apache server: Aka, the location /auth is password protected by Perl*Handlers and usually i only write other PerlHandlers that do things under that location. However, i need to put a .shtml file into that diretory (it is also a normal directory under the document root). Putting .html files there is no problem, they display fine, however, .shtml files do not get parsed when in that directory (they work fine from everywhere else on the server). I assume this is because under that directory, SetHandler is set to perl-script and not server-parsed? Is there a way i can use the "Files" directive (or any other way) to get the server to parse .shtml files in that directory? simran.
Help - SEGFAULTS on 'PerlModule' after version upgrade
Ugggh: My software works with the 'original server settings', (apache 1.3.24/mod_perl 1.26) see below(1), under linux. It doesn't work with 'new server settings', (apache 1.3.26 / mod_perl 1.26) see below(2), under freeBSD. Symptoms: With the new build, I get seg faults with 'some' of the PerlModules included through PerlModule in various virtualhosts. Other modules work. These packages all run with strict and do not include any XS besides what may hide under the cover with DBI, Date::Calc and Template. I also have a headache. The packages were happily being included into my old build and there is nothing unusual about them. An strace displays the last couple of lines before a segfault as follows: Server Settings follow this Block=== stat("/usr/local/lib/perl5/site_perl/5.005/i386-freebsd/auto/Date/Calc/Calc.bs", {st_mode=S_IFREG|0444, st_size=0, ...}) = 0 sigprocmask(SIG_BLOCK, ~[ILL TRAP ABRT EMT FPE BUS SEGV SYS], []) = 0 open("/usr/local/lib/perl5/site_perl/5.005/i386-freebsd/auto/Date/Calc/Calc.so", O_RDONLY) = 7 fstat(7, {st_mode=S_IFREG|0555, st_size=105794, ...}) = 0 read(7, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 )\0\000"..., 4096) = 4096 mmap(0, 102400, PROT_READ|PROT_EXEC, MAP_PRIVATE, 7, 0) = 0x28316000 mmap(0x2832e000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0x17000) = 0x2832e000 close(7)= 0 access("/usr/lib/libperl.so.3", F_OK) = 0 open("/usr/lib/libperl.so.3", O_RDONLY) = 7 fstat(7, {st_mode=S_IFREG|0444, st_size=615768, ...}) = 0 read(7, "\177ELF\1\1\1\t\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0|O\1\000"..., 4096) = 4096 mmap(0, 622592, PROT_READ|PROT_EXEC, MAP_PRIVATE, 7, 0) = 0x2832f000 mmap(0x283bd000, 36864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0x8d000) = 0x283bd000 mmap(0x283c6000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANON, -1, 0) = 0x283c6000 close(7)= 0 access("/usr/lib/libm.so.2", F_OK) = 0 access("/usr/lib/libm.so.2", F_OK) = 0 access("/usr/lib/libutil.so.3", F_OK) = 0 sigprocmask(SIG_SETMASK, [], NULL) = 0 sigprocmask(SIG_BLOCK, ~[ILL TRAP ABRT EMT FPE BUS SEGV SYS], []) = 0 sigprocmask(SIG_SETMASK, [], NULL) = 0 --- SIGSEGV (Segmentation fault) --- --- SIGSEGV (Segmentation fault) --- === Can someone please help?? I can provide a fuller strace if someone might be able to decipher my problem from this. Very, very, lost, Cheers, Rafiq SERVER CONFIGS: (1)'original server settings' - Server version: Apache/1.3.24 (Unix) Modperl: 1.26 Compiled-in modules: http_core.c mod_so.c Server compiled with -D EAPI -D HAVE_MMAP -D HAVE_SHMGET -D USE_SHMGET_SCOREBOARD -D USE_MMAP_FILES -D HAVE_FCNTL_SERIALIZED_ACCEPT -D HAVE_SYSVSEM_SERIALIZED_ACCEPT -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D HTTPD_ROOT="/usr/local/apache" -D SUEXEC_BIN="/usr/local/apache/bin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/httpd.scoreboard" -D DEFAULT_LOCKFILE="logs/httpd.lock" -D DEFAULT_XFERLOG="logs/access_log" -D DEFAULT_ERRORLOG="logs/error_log" -D TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" -D ACCESS_CONFIG_FILE="conf/access.conf" -D RESOURCE_CONFIG_FILE="conf/srm.conf" (2)'new server settings': - Server version: Apache/1.3.26 (Unix) Mod_Perl: 1.26 Compiled-in modules: http_core.c mod_so.c Server compiled with -D HAVE_MMAP -D USE_MMAP_SCOREBOARD -D USE_MMAP_FILES -D HAVE_FLOCK_SERIALIZED_ACCEPT -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D SO_ACCEPTFILTER -D ACCEPT_FILTER_NAME="httpready" -D HTTPD_ROOT="/usr/local" -D SUEXEC_BIN="/usr/local/sbin/suexec" -D DEFAULT_PIDLOG="/var/run/httpd.pid" -D DEFAULT_SCOREBOARD="/var/run/httpd.scoreboard" -D DEFAULT_LOCKFILE="/var/run/httpd.lock" -D DEFAULT_ERRORLOG="/var/log/httpd-error.log" -D TYPES_CONFIG_FILE="etc/apache/mime.types" -D SERVER_CONFIG_FILE="etc/apache/httpd.conf" -D ACCESS_CONFIG_FILE="etc/apache/access.conf" -D RESOURCE_CONFIG_FILE="etc/apache/srm.conf"
@INC + use Lib
I've been having problems with use lib. I read the extract at http://perl.apache.org/docs/1.0/guide/porting.html#_INC_and_mod_perl and realised that you can hardcode @INC via httpd.conf or startup.pl. however, i tried adding PerlSetEnv PERL5LIB to a .htaccess file but that doesn't seem to work!? Is there someway to isolate the paths to specific virtualhosts or directories? I tried adding it within a directory command in httpd.conf but it didn't seem to work. Am I going about this in the right way? Pierre
Re: Server Parsed .shtml files...
simran wrote: Hi All, I have a auth protected area for the apache server: Aka, the location /auth is password protected by Perl*Handlers and usually i only write other PerlHandlers that do things under that location. However, i need to put a .shtml file into that diretory (it is also a normal directory under the document root). Putting .html files there is no problem, they display fine, however, .shtml files do not get parsed when in that directory (they work fine from everywhere else on the server). I assume this is because under that directory, SetHandler is set to perl-script and not server-parsed? yes, exactly. SetHandler gets the highest priority, and overrides things such as AddHandler you may have set elsewhere. Is there a way i can use the "Files" directive (or any other way) to get the server to parse .shtml files in that directory? won't help you once you're in the covered by SetHandler (at least I don't think so, but it's early). I'd probably write a PerlFixupHandler to undo the SetHandler for .shtml files or something if you really needed to override your global SetHandler for a given . it's generally as simple as $r->handler('server-parsed') if $r->filename =~ m!\.shtml$!; but you could probably just as easily remove the SetHandler perl-script in that directory and exchange it for the proper set of AddHandler directives. HTH --Geoff
Server Parsed .shtml files...
Hi All, I have a auth protected area for the apache server: Aka, the location /auth is password protected by Perl*Handlers and usually i only write other PerlHandlers that do things under that location. However, i need to put a .shtml file into that diretory (it is also a normal directory under the document root). Putting .html files there is no problem, they display fine, however, .shtml files do not get parsed when in that directory (they work fine from everywhere else on the server). I assume this is because under that directory, SetHandler is set to perl-script and not server-parsed? Is there a way i can use the "Files" directive (or any other way) to get the server to parse .shtml files in that directory? simran.