Re: Apache, mod_perl, mod_proxy, mod_rewrite
Serguei Trouchelle wrote: error.log says following: [error] proxy:http://naive1.isd.dp.ua/cgi-bin/system-select-isd-request.pl not found or unable to stat But request to http://naive1.isd.dp.ua/cgi-bin/system-select-isd-request.pl was successful. What's up? I found what is up. Apache::Registry and Apache::PerlRun cannot handle request proxy:http://naive1.isd.dp.ua/cgi-bin/system-select-isd-request.pl So another question (sadly that nobody answers to first one): why request, meant to proxy, is sending to Apache::Registry or Apache::PerlRun? -- Serguei Trouchelle http://www.isd.dp.ua/
Apache, mod_perl, mod_proxy, mod_rewrite
Today I tried to change my cgi-scripts to mod_perl ones. I used mod_rewrite and mod_proxy just like this: RewriteRule ^/system/select/isd/request/$ /cgi-bin/system-select-isd-request.cgi [P] But when I tried to change to mod_perl RewriteRule ^/system/select/isd/request/$ /cgi-bin/system-select-isd-request.pl [P] I've got 404 Not Found error: The requested URL /system/select/isd/request/ was not found on this server. error.log says following: [error] proxy:http://naive1.isd.dp.ua/cgi-bin/system-select-isd-request.pl not found or unable to stat But request to http://naive1.isd.dp.ua/cgi-bin/system-select-isd-request.pl was successful. What's up? -- Serguei Trouchelle http://www.isd.dp.ua/
Re: mod_rewrite + PerlTransHandler
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Mon, 20 Jan 2003 10:10:36 +1100, Stas Bekman wrote: Not in mod_perl 1.0. Your best bet is probably to move the mod_rewrite's rules into your perl transhandler. or maybe just have mod_rewrite take precedence over mod_perl, by having LoadModule mod_rewrite after mod_perl's? cheers, [EMAIL PROTECTED] - wa1800z@DALnetCAiRC - #32741432 KeyID 0xDE9EB50B - D0D87CA98916CBB258AC 77FB91E0DA95DE9EB50B -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+K9+4keDald6etQsRAid0AJ48NUaxGwFIwDw9Kzfq0AVwTZ1bVgCfdgwe tnAu1NE/HanCb4RKIw/b6s0= =uVGf -END PGP SIGNATURE-
mod_rewrite + PerlTransHandler
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I am trying to get a PerlTransHandler called *after* some mod_rewrite processing. I thought if I configure the rewrite rules *before* the PerlTransHandler: RewriteEngine On RewriteRule ... [PT] PerlTransHandler Apache::TestTrans::transhandler it would work that way. But it does not. Apache::TestTrans::transhandler is always called *before* mod_rewrite processing. Is there a way to determine the handler order? Thanks Torsten -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE+Kt+/wicyCTir8T4RAqmNAJsGfm6CaPueSjCRAIA/BZ1BgWtxxACfWCLY GAo8nB1xxL1r+7blx7+qbi8= =473P -END PGP SIGNATURE-
Re: mod_rewrite + PerlTransHandler
Torsten Foertsch wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I am trying to get a PerlTransHandler called *after* some mod_rewrite processing. I thought if I configure the rewrite rules *before* the PerlTransHandler: RewriteEngine On RewriteRule ... [PT] PerlTransHandler Apache::TestTrans::transhandler it would work that way. But it does not. Apache::TestTrans::transhandler is always called *before* mod_rewrite processing. Is there a way to determine the handler order? Not in mod_perl 1.0. Your best bet is probably to move the mod_rewrite's rules into your perl transhandler. It should be possible in 2.0, though the API is not there yet. Apache 2.0 allows to insert handlers before/after a specified handler + other options. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Problem combining mod_proxy, mod_rewrite mod_perl
G'day! I would like to combine mod_proxy, mod_rewrite and mod_perl on an Apache 2.0.43 for Windows with mod_perl 2.0. The Perl Version I use is ActiveState 5.6.1. Just by loading the module the server behaves differently. Instead seeing the the reverse proxied site I get following error in the browser: - Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/. Reason: Max-Forwards has reached zero - proxy loop? - It seems as if the rewrite rules are applied in a recursive loop. The rewrite.log does support this. Any ideas why this is happening and how can I get the config running again. Regards Jan -- The rewrite log does look like this: sid#4ade80][rid#484888/initial] (2) init rewrite engine with requested uri / sid#4ade80][rid#484888/initial] (3) applying pattern '^/(.*)' to uri '/' sid#4ade80][rid#484888/initial] (2) rewrite / - /directx/ sid#4ade80][rid#484888/initial] (2) forcing proxy-throughput with http://192.168.X.X/directx/ sid#4ade80][rid#484888/initial] (1) go-ahead with proxy request proxy:http://192.168.X.X/directx/ [OK] sid#4ade80][rid#48a8a0/initial] (2) init rewrite engine with requested uri /directx/ sid#4ade80][rid#48a8a0/initial] (3) applying pattern '^/(.*)' to uri '/directx/' sid#4ade80][rid#48a8a0/initial] (2) rewrite /directx/ - /directx/directx/ sid#4ade80][rid#48a8a0/initial] (2) forcing proxy-throughput with http://192.168.X.X/directx/directx/ sid#4ade80][rid#48a8a0/initial] (1) go-ahead with proxy request proxy:http://192.168.X.X/directx/directx/ [OK] ... { Shortend } - I have following httpd.conf (shortend): LoadFile C:/Perl/bin/perl56.dll LoadModule access_module modules/mod_access.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_module modules/mod_auth.so LoadModule autoindex_module modules/mod_autoindex.so LoadModule cgi_module modules/mod_cgi.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so LoadModule imap_module modules/mod_imap.so LoadModule include_module modules/mod_include.so LoadModule isapi_module modules/mod_isapi.so LoadModule log_config_module modules/mod_log_config.so LoadModule mime_module modules/mod_mime.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule rewrite_module modules/mod_rewrite.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule userdir_module modules/mod_userdir.so LoadModule ssl_module modules/mod_ssl.so LoadModule perl_module modules/mod_perl.so VirtualHost 1192.168.X.X:81 ServerName foo.bar DocumentRoot /htdocs_rp RewriteEngine On RewriteLog logs/rewrite.log RewriteLogLevel 9 RewriteRule ^/inject$ /tap1/inject.html [P] RewriteRule ^/(.*) /directx1/$1 [P] ProxyPass /tap1/ http://127.0.0.1/ ProxyPassReverse / http://127.0.0.1/ ProxyPass /directx1/ http://acm.org/ ProxyPassReverse / http://acm.org/ /VirtualHost
Re: Problem combining mod_proxy, mod_rewrite mod_perl
Jan P. Monsch wrote: G'day! I would like to combine mod_proxy, mod_rewrite and mod_perl on an Apache 2.0.43 for Windows with mod_perl 2.0. The Perl Version I use is ActiveState 5.6.1. Just by loading the module the server behaves differently. Instead seeing the the reverse proxied site I get following error in the browser: - Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/directx1/. Reason: Max-Forwards has reached zero - proxy loop? - It seems as if the rewrite rules are applied in a recursive loop. The rewrite.log does support this. Any ideas why this is happening and how can I get the config running again. [...] From your explanations and debug traces it looks like a bug in mod_proxy/mod_rewrite. You probably will get the same story with mod_cgi. If so, you need to report this bug to the httpd-dev list. __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: mod_perl + mod_rewrite
P. Zadikian wrote: Hello, Is there some way to set mod_rewrite rules in a Perl/Perl section in the apache configuration? Just like any other httpd configuration, as explained here: http://perl.apache.org/docs/1.0/guide/config.html#Apache_Configuration_in_Perl and in much more detail in the eagle and the cookbook. You can even write your own PerlTransHandler which will do the rewrite... __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
mod_perl + mod_rewrite
Hello, Is there some way to set mod_rewrite rules in a Perl/Perl section in the apache configuration? Thanks, Z.
reading an ENV with Perl that was set with mod_rewrite [E= : ]
Hi, Has anyone used mod_rewrite to set an environmental variable based on the result of a reg exp? For example: RewriteRule ^/pt=([^/]+)?(.*) /home/me.com/public_html/$2 [E=PT:$1] I can get a static url like: RewriteRule /perl /usr/local/apache/perl/printenv [E=ERIC:bob] to work, but the first one I can't. PT doesn't exist, but ERIC does. I know this is not exactly on topic, but it is a weird sort of issue, the admin I was dealing with said he could get the above ENV with PHP or mod_perl but not with perl CGI's I can't seem to get it with a mod_perl Registry script either though. Thanks, Eric http://www.kwinternet.com/eric (250) 655 - 9513 (PST Time Zone) Inquiry is fatal to certainty. -- Will Durant
Re: mod_rewrite + mod_perl
KS == Kenny Smith [EMAIL PROTECTED] writes: KS It executes show_journal.mod_perl perfectly well, but the script does not KS remain resident in memory. Do I need to call it differently? Any help is KS appreciated. :) What evidence do you have to say it doesn't remain resident? -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/
mod_rewrite + mod_perl
Hello all, For the first part of my project, I'm just using mod_perl as a replacement for CGI. I'm trying to execute a mod_perl script via mod_rewrite, but it doesn't seem to be persisting. In my httpd.conf, I've got: Files *.mod_perl SetHandler perl-script PerlHandler Apache::Registry PerlSendHeader On Options ExecCGI /Files ... RewriteRule ^/([^/^.]+)/?$ /path/show_journal.mod_perl [T=application/x-httpd-cgi,E=NICKNAME:$1,L] The above is used to catch the following URL: http://www.journalscape.com/kenny/ The nickname 'kenny' is captured from the url and sent to the script via an environment variable. It executes show_journal.mod_perl perfectly well, but the script does not remain resident in memory. Do I need to call it differently? Any help is appreciated. :) Kenny Smith [EMAIL PROTECTED]
Mod_rewrite
Can mod_rewrite be used to set PerlSetVar or PerlSetEnv variables? Jamie Krasnoo [EMAIL PROTECTED]
RE: Mod_rewrite
-Original Message- From: Jamie Krasnoo [mailto:[EMAIL PROTECTED]] Sent: Friday, June 22, 2001 3:14 PM To: Modperl Subject: Mod_rewrite Can mod_rewrite be used to set PerlSetVar or PerlSetEnv variables? well, both of these are used to populate Apache::Table objects internal to mod_perl. you may be able to finagle something with with PerlSetupEnv On and the E RewriteRule flag for $r-subprocess_env, but it wouldn't make sense to be able to populate $r-dir_config outside of normal routes. --Geoff
[OT?] %ENV question, mod_rewrite vs. mod_perl?
I'm new to mod_perl, so please bear with me a bit. I'm digging through as much information as I can find and have a few questions. I've used mod_rewrite for a lot of URI re-mapping solutions, but this particular job I'm doing is a bit of a challenge. I have an existing perl script (non mod_perl) which checks against a number of ENV variables to determine which 'file' the browser should see. Trouble is, that script reads the file and spits it out to the browser, which makes it useless for anything with SSI or PHP based solutions. My logic had me thinking that I could use mod_rewrite to query the script, and rewrite the URI slightly according to what that script spit back. Then apache could fill the request and SSI and PHP stuff would remain intact (and be parsed). So I wind up with RewriteEngine on RewriteLogLevel 9 RewriteLog /home/httpd/logs/rewrite.log RewriteMapfoo prg:/home/httpd/cgi-bin/foo.cgi RewriteRule ^/(.+\.(html|htm|php|php3))$ /${foo:$1} [L] which basically says, pass the URI to foo and give back a rewritten URI, then go fetch it. trouble is, due to the way the Map works, the foo.cgi is launched then 'stays' launched, and from what I can tell has no access to the %ENV variables that it would normally have available if it was run as a normal cgi script. So, this lead me to mod_perl. Is mod_perl a solution in this case? If so, would it be a total replacement for the RewriteEngine in this example? Is there a mod_perl script/module that already does URI rewriting that I can use for reference? Or, Does anyone know how I could possibly make the %ENV available to foo.cgi in a case like the above? Thanks for any and all pointers if answering with ROTFM, please point me to a URL or chapter ;-) - Paul -- - Kudosnet Technologies Inc. - Support: [EMAIL PROTECTED] Accounts: [EMAIL PROTECTED] Sales: [EMAIL PROTECTED] 1-877-885-8367 --
Re: [OT?] %ENV question, mod_rewrite vs. mod_perl?
Use a mod_perl transhandler for this, it's the phase of the apache process that's responsible for matching the URI/request to a file that'll be executed in the response phase. http://perl.apache.org/guide/snippets.html#PerlTransHandler_example -sc On Mon, Mar 19, 2001 at 07:42:14PM -0800, Paul Evad wrote: Delivered-To: [EMAIL PROTECTED] Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm Precedence: bulk list-help: mailto:[EMAIL PROTECTED] list-unsubscribe: mailto:[EMAIL PROTECTED] list-post: mailto:[EMAIL PROTECTED] Delivered-To: mailing list [EMAIL PROTECTED] X-Sender: [EMAIL PROTECTED] Date: Mon, 19 Mar 2001 19:42:14 -0800 To: [EMAIL PROTECTED] From: Paul Evad [EMAIL PROTECTED] Subject: [OT?] %ENV question, mod_rewrite vs. mod_perl? X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N I'm new to mod_perl, so please bear with me a bit. I'm digging through as much information as I can find and have a few questions. I've used mod_rewrite for a lot of URI re-mapping solutions, but this particular job I'm doing is a bit of a challenge. I have an existing perl script (non mod_perl) which checks against a number of ENV variables to determine which 'file' the browser should see. Trouble is, that script reads the file and spits it out to the browser, which makes it useless for anything with SSI or PHP based solutions. My logic had me thinking that I could use mod_rewrite to query the script, and rewrite the URI slightly according to what that script spit back. Then apache could fill the request and SSI and PHP stuff would remain intact (and be parsed). So I wind up with RewriteEngine on RewriteLogLevel 9 RewriteLog /home/httpd/logs/rewrite.log RewriteMapfoo prg:/home/httpd/cgi-bin/foo.cgi RewriteRule ^/(.+\.(html|htm|php|php3))$ /${foo:$1} [L] which basically says, pass the URI to foo and give back a rewritten URI, then go fetch it. trouble is, due to the way the Map works, the foo.cgi is launched then 'stays' launched, and from what I can tell has no access to the %ENV variables that it would normally have available if it was run as a normal cgi script. So, this lead me to mod_perl. Is mod_perl a solution in this case? If so, would it be a total replacement for the RewriteEngine in this example? Is there a mod_perl script/module that already does URI rewriting that I can use for reference? Or, Does anyone know how I could possibly make the %ENV available to foo.cgi in a case like the above? Thanks for any and all pointers if answering with ROTFM, please point me to a URL or chapter ;-) - Paul -- - Kudosnet Technologies Inc. - Support: [EMAIL PROTECTED] Accounts: [EMAIL PROTECTED] Sales: [EMAIL PROTECTED] 1-877-885-8367 -- -- Sean Chittenden[EMAIL PROTECTED] PGP signature
Segfaults with mod_rewrite
I've been looking for this segfault for a while. This may be related to my last post about the double requests under mod_perl because if I use a cgi-script instead of a mod_perl handler I don't get the segfault. But there's an issue with mod_rewrite, too. I have a url that can go to an advanced search page: http://localhost/search/advanced/extra/path Everything after /search is extra path info. I thought it would be nice to make it easy to use: http://localhost/advanced/extra/path So, I was using this rewrite rule: RewriteRule ^/(foo|bar|advanced)(.*) /search/$1$2 But that's causing a segfault. My guess is that /search/advanced/extra/path ends up with a subrequest of /advanced/extra/path And the rewrite_log shows that happening. Interesting, is that although this causes the segfaults RewriteRule ^/(foo|bar|advanced)(.*) /search/$1$2 this works fine: RewriteRule ^/(advanced)(.*) /search/$1$2 Looks like a bug in mod_rewrite, too. Here's the httpd.conf: VirtualHost *:9000 RewriteEngine on RewriteLogLevel 9 RewriteLog rewrite_log RewriteRule ^/(foo|bar|advanced)(.*) /search/$1$2 perl package My::Hello; use strict; use Apache::Constants qw( OK ); sub handler { my $r = shift; $r-send_http_header('text/plain'); $r-print('hello'); return OK; } /perl Location /search Allow from all SetHandler perl-script PerlHandler My::Hello PerlSendHeader on /Location /VirtualHost And here's the backtrace: Program received signal SIGSEGV, Segmentation fault. 0x4012c65c in memset (dstpp=0x0, c=0, len=3355583254) at ../sysdeps/i386/memset.c:64 64 ../sysdeps/i386/memset.c: No such file or directory. (gdb) bt #0 0x4012c65c in memset (dstpp=0x0, c=0, len=3355583254) at ../sysdeps/i386/memset.c:64 #1 0x809d25a in ap_pcalloc () #2 0x80bb39e in ap_pregsub () #3 0x807bfa6 in expand_backref_inbuffer () #4 0x807a8e8 in apply_rewrite_rule () #5 0x8079ea1 in apply_rewrite_list () #6 0x8078a37 in hook_uri2file () #7 0x80a2254 in run_method () #8 0x80a22d4 in ap_translate_name () #9 0x80b79d9 in ap_sub_req_method_uri () #10 0x80b7bb5 in ap_sub_req_lookup_uri () #11 0x80c0214 in ap_add_cgi_vars () #12 0x808b66a in perl_cgi_env_init () #13 0x8086042 in perl_setup_env () #14 0x8085722 in perl_per_request_init () #15 0x80858ea in perl_call_handler () #16 0x8085636 in perl_run_stacked_handlers () #17 0x808418d in perl_handler () #18 0x80a27b3 in ap_invoke_handler () #19 0x80b8af9 in process_request_internal () #20 0x80b8b5c in ap_process_request () #21 0x80af1f9 in child_main () #22 0x80af3b8 in make_child () #23 0x80af543 in startup_children () #24 0x80afbe4 in standalone_main () #25 0x80b0463 in main () #26 0x400e2313 in __libc_start_main (main=0x80b0080 main, argc=3, argv=0xb8d4, init=0x8062188 _init, fini=0x8156ef8 _fini, rtld_fini=0x4000ac70 _dl_fini, stack_end=0xb8cc) at ../sysdeps/generic/libc-start.c:90 (gdb) Bill Moseley mailto:[EMAIL PROTECTED]
[mod_rewrite] Remember to set your logLevel down!
hi, I've got a 2 tier apache setup running a lightweight apache with mod_rewrite proxying *.pl requests to the heavyweight apache. I'm posting this to share a bit of practical info on how to build such a setup on a per-file basis, as the Guide only deals with per domain/directory rewriting/proxying. The aim is to proxy requests to a mod_perl enabled apache running on a high port, based on file extension, and enabling a transparent transition from a monolothic one-apache setup to a 2 tier setup. As a matter of fact, I keep a single apache on my dev box, and I'm upgrading the production server to handle static + CGI + server-parsed content with apache.plain, and proxy Registry and Embperl to apache.perl (running on port 1800). Additionally, requests for any PHP content will be proxied to apache.php at port 1801. To achieve this, I used to have in httpd.conf RewriteEngine ON RewriteLogLevel 3 RewriteLog /projects/webserver/logs/rewrite_log RewriteCond %{REQUEST_FILENAME} \.(pl|ehtml)$ RewriteRule ^/(.*) http://%{HTTP_HOST}:1800/$1 [P] The issue is that PLAIN requests, that do not get proxied are getting a performance hit because each hit executes 2 regexes on the URL: the RewriteRule and the RewriteCond. At the beggining, I was horrified at the performance, because I had logging on. See: Without Rewriting: 510 requests per second With LogLevel 0: 418 req/s With LogLevel 1: 365 req/s With LogLevel 3: 300 req/s Calling test.pl at port 1800: 85 req/s Calling test.pl through proxy: 70 req/s One of the interesting things I found is that the statically compiled apache.perl serves static content a little slower than the mod_so (ENABLE_SHARED=MAX) apache.plain: 510 req/s against 470 req/s. My guess is that the extra handlers that mod_perl registers slow down things a bit more than the usage of mod_so (which the docs estimate to be 5%). martin
Re: [OT] mod_rewrite hang
Thanks for the people who tried to help, but it doesn't seem to be a DNS timeout. When using the following code, it still hangs: #!/usr/bin/perl -w use strict; $|++; while(){ print "$_\n"; } Any other suggestions? Jonathan Leto ([EMAIL PROTECTED]) was saying: If anybody could give me some insight on the problem I am having, it would be greatly appreciated. I have been working on this all day, and I just can't get past this roadblock. Situation: Using mod_rewrite's RewriteMap functionality with an external rewrite rewrite map ( a perl script ). Tested on 3 Linux 2.2/Apache 1.3.12 webservers. Two act exactly as they should, and one waits *exactly* 3 minutes, then does what it should. Details: Apache Config: RewriteLock /var/lock/findurl.lock RewriteEngine on RewriteLog /www/logs/rewrite RewriteMapfind prg:/www/bin/findurl.pl RewriteLogLevel 3 RewriteRule ^(/~.*) ${find:$1:%{SERVER_PORT}} findurl.pl finds content on other webservers and rewrites the url. This works perfectly on 2 of my webservers, and on one it just hangs for 3 minutes. mod_rewrite takes 3 minutes: 192.x.x.x - - [02/Sep/2000:22:05:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) init rewrite engine with requested uri /~asdf/ 192.x.x.x - - [02/Sep/2000:22:05:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (3) applying pattern '^(/~.*)' to uri '/~asdf/' 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) rewrite /~asdf/ - http://www2.tlink.net/~asdf/ 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) implicitly forcing redirect (rc=302) with http://www2.tlink.net/~asdf/ 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (1) escaping http://www2.tlink.net/~asdf/ for redirect 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (1) redirect to http://www2.tlink.net/~asdf/ [REDIRECT/302] 192.x.x.x - - [02/Sep/2000:23:28:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) init rewrite engine with requested uri /~pleasework/ 192.x.x.x - - [02/Sep/2000:23:28:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (3) applying pattern '^(/~.*)' to uri '/~pleasework/' 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) rewrite /~pleasework/ - http://www2.tlink.net/~pleasework/ 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) implicitly forcing redirect (rc=302) with http://www2.tlink.net/~pleasework/ 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (1) escaping http://www2.tlink.net/~pleasework/ for redirect 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (1) redirect to http://www2.tlink.net/~pleasework/ [REDIRECT/302] The hanging occurs before it even gets to my perl script, which has me stumped. All servers are Apache 1.3.12, Linux 2.2, perl 5.005_03. Can anybody help? -- [EMAIL PROTECTED] "With pain comes clarity." -- [EMAIL PROTECTED] "With pain comes clarity."
Re: [OT] mod_rewrite hang
Jonathan Leto [EMAIL PROTECTED] writes: Thanks for the people who tried to help, but it doesn't seem to be a DNS timeout. When using the following code, it still hangs: #!/usr/bin/perl -w use strict; $|++; while(){ print "$_\n"; } strace the server under 'httpd -X' -- Dave Hodgkinson, http://www.hodgkinson.org Editor-in-chief, The Highway Star http://www.deep-purple.com Apache, mod_perl, MySQL, Sybase hired gun for, well, hire -
[OT] mod_rewrite hang
If anybody could give me some insight on the problem I am having, it would be greatly appreciated. I have been working on this all day, and I just can't get past this roadblock. Situation: Using mod_rewrite's RewriteMap functionality with an external rewrite rewrite map ( a perl script ). Tested on 3 Linux 2.2/Apache 1.3.12 webservers. Two act exactly as they should, and one waits *exactly* 3 minutes, then does what it should. Details: Apache Config: RewriteLock /var/lock/findurl.lock RewriteEngine on RewriteLog /www/logs/rewrite RewriteMapfind prg:/www/bin/findurl.pl RewriteLogLevel 3 RewriteRule ^(/~.*) ${find:$1:%{SERVER_PORT}} findurl.pl finds content on other webservers and rewrites the url. This works perfectly on 2 of my webservers, and on one it just hangs for 3 minutes. mod_rewrite takes 3 minutes: 192.x.x.x - - [02/Sep/2000:22:05:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) init rewrite engine with requested uri /~asdf/ 192.x.x.x - - [02/Sep/2000:22:05:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (3) applying pattern '^(/~.*)' to uri '/~asdf/' 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) rewrite /~asdf/ - http://www2.tlink.net/~asdf/ 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (2) implicitly forcing redirect (rc=302) with http://www2.tlink.net/~asdf/ 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (1) escaping http://www2.tlink.net/~asdf/ for redirect 192.x.x.x - - [02/Sep/2000:22:08:27 -0400] [www.tlink.net/sid#82d6724][rid#83dc41c/initial] (1) redirect to http://www2.tlink.net/~asdf/ [REDIRECT/302] 192.x.x.x - - [02/Sep/2000:23:28:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) init rewrite engine with requested uri /~pleasework/ 192.x.x.x - - [02/Sep/2000:23:28:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (3) applying pattern '^(/~.*)' to uri '/~pleasework/' 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) rewrite /~pleasework/ - http://www2.tlink.net/~pleasework/ 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (2) implicitly forcing redirect (rc=302) with http://www2.tlink.net/~pleasework/ 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (1) escaping http://www2.tlink.net/~pleasework/ for redirect 192.x.x.x - - [02/Sep/2000:23:31:25 -0400] [www.tlink.net/sid#82f6c8c][rid#83fa96c/initial] (1) redirect to http://www2.tlink.net/~pleasework/ [REDIRECT/302] The hanging occurs before it even gets to my perl script, which has me stumped. All servers are Apache 1.3.12, Linux 2.2, perl 5.005_03. Can anybody help? -- [EMAIL PROTECTED] "With pain comes clarity."
problem with mod_proxy/mod_rewrite being used for the front-end proxy
This isn't entirely on-topic but it's a solution often suggested for mod_perl users so I suspect there are other users here being bitten by the same problems. In fact the manner in which problems manifest are such that it's possible that many mod_perl users who are using mod_rewrite/mod_proxy to run a reverse proxy in front of their heavyweight perl servers have a security problem and don't even know it. The problem is that the solution written in the mod_rewrite guide for a reverse proxy doesn't work as advertised to block incoming proxy requests. RewriteRule^(http|ftp)://.* - [F] This is supposed to block incoming proxy requests that aren't specifically created by the rewrite rules that follow. The problem is that both mod_rewrite and mod_proxy have changed, and this seems to no longer catch the incoming proxy requests. Instead mod_rewrite seems to see just the path part of the URI, ie, /foo/bar/baz.pl without the http://.../. I've even tried using ${THE_REQUEST} which actually matches, and says it's forcing the response to be forbidden, then it happily proxies the request anyways! I'm using a Directory proxy:* deny from all /Directory Directory proxy:http://127.0.0.1/ allow from all /Directory section to at least avoid being an open proxy to the outside world, but I cannot find any way in 1.3.12 to refuse all proxy requests coming from the outside. If you're not aware of the problem at all and have merely followed the advice of the mod_rewrite guide you are probably an open proxy, allowing attackers to use your web server to attack other sites anonymously. -- greg
Re: problem with mod_proxy/mod_rewrite being used for the front-end proxy
According to Greg Stark: This isn't entirely on-topic but it's a solution often suggested for mod_perl users so I suspect there are other users here being bitten by the same problems. In fact the manner in which problems manifest are such that it's possible that many mod_perl users who are using mod_rewrite/mod_proxy to run a reverse proxy in front of their heavyweight perl servers have a security problem and don't even know it. The problem is that the solution written in the mod_rewrite guide for a reverse proxy doesn't work as advertised to block incoming proxy requests. RewriteRule^(http|ftp)://.* - [F] This is supposed to block incoming proxy requests that aren't specifically created by the rewrite rules that follow. The problem is that both mod_rewrite and mod_proxy have changed, and this seems to no longer catch the incoming proxy requests. Instead mod_rewrite seems to see just the path part of the URI, ie, /foo/bar/baz.pl without the http://.../. Setting ProxyRequests off should disable any explict proxy requests from clients. It does not stop ProxyPass or RewriteRule specified proxying. My server logs a 302 error and sends a redirect to http://www.goto.com/d/home/p/digimedia/context/ (interesting - I didn't know where it was redirecting before...). I do see quite a few of these in my logfiles, mostly trying to bump up the ad counters on some other sites, I think. Les Mikesell [EMAIL PROTECTED]
[OT] strange mod_rewrite behaviour (for Apache::Session support)
Hello, I am in the process of implementing persistent sessions using Apache::Session with the session_id stored in the URL and it mostly works. In the HTML::Mason autohandler there is the following filter: %filter $r-pnotes("cookie") # mangle URL only if cookie is missing || s#\bhref\s*=\s*"(/(?!S=)[^"\s]*)"#href="/S=$session{_session_id}$1"#gi; /%filter ... which adds the session_id to all href links, only if the browser doesn't return any cookie. Now in httpd.conf there is a mod_rewrite rule inspired by a recent thread on the modperl list: RewriteRule ^/S=([^/]+)(/.*) $2 [E=AF_SID:$1] This removes the session_id from the URL and adds it to the AF_SID environment variable. This works well for all absolute URLs (starting with a /) which is puzzling because I remember reading in this thread that this technique mandated _relative_ URLs. The rewrite rule fails only in one case, the root URL: http://my.site.com/S=1d2e580af1e31cf2/Sell/index.html ... is correctly converted to http://my.site.com/Sell/index.html ... *but* http://my.site.com/S=1d2e580af1e31cf2/ ... fails with a 404 NOT FOUND error From the rewrite log: 127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464 /initial] (2) init rewrite engine with requested uri /S=3b2c1685dcc26394/ 127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464 /initial] (3) applying pattern '^/S=([^/]+)(/.*)' to uri '/S=3b2c1685dcc26394/' 127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464 /initial] (2) rewrite /S=3b2c1685dcc26394/ - / 127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464 /initial] (2) local path result: / 127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464 /initial] (1) go-ahead with / [OK] [Sun Jul 23 15:57:31 2000] [error] [client 127.0.0.1] File does not exist: / ... so after tinkering with various mod_rewrite options for a while I changed the RewriteRule to: RewriteRule ^/S=([^/]+)(/.*) %{DOCUMENT_ROOT}$2 [E=AF_SID:$1] ... and now everything works fine. But I'm still not happy because I don't understand _why_ it works. Please let me know if you have a rational explanation. TIA -- Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.fr # rm *;o o : command not found
Re: [OT] mod_rewrite
I would like to thank the many people on list for offering help for my mod_rewrite problem. I think I have it figured out, but for those of you who e-mailed me off list I am going to send you a snippet of my code, just to make sure I am not totally off of my rocker :) Once again, thank you. Jeff Jones On Fri, 21 Jul 2000, Gunther Birznieks wrote: If it has to do with your setup of mod_perl, why dont you just post your config here..I can't believe it would be more than 10-15 lines long..? At 03:11 PM 7/20/00 -0500, Jeff Jones wrote: It's the mod_rewrite guy again. Is there anyone who would be willing to provide some off list assistance? I just want to run a configuration by someone who knows more about this than I do and see if I am doing it right. Thanks again, Jeff Jones __ Gunther Birznieks ([EMAIL PROTECTED]) eXtropia - The Web Technology Company http://www.extropia.com/
Re: [OT] mod_rewrite
If it has to do with your setup of mod_perl, why dont you just post your config here..I can't believe it would be more than 10-15 lines long..? At 03:11 PM 7/20/00 -0500, Jeff Jones wrote: It's the mod_rewrite guy again. Is there anyone who would be willing to provide some off list assistance? I just want to run a configuration by someone who knows more about this than I do and see if I am doing it right. Thanks again, Jeff Jones __ Gunther Birznieks ([EMAIL PROTECTED]) eXtropia - The Web Technology Company http://www.extropia.com/
Re: [OT] mod_rewrite
Hi there, On Thu, 20 Jul 2000, Jeff Jones wrote: It's the mod_rewrite guy again. Is there anyone who would be willing to provide some off list assistance? I just want to run a configuration by someone who knows more about this than I do and see if I am doing it right. I'd say as long as you are as considerate as you have been (by putting the OT flag in your subject line) then post your rewrite rules to the list and wait for the bang. I'll give it a go if it's regular expressions which you're bothered about but there are many more people on the List with far more experience of mod_rewrite than I have. 73, Ged.
[OT] mod_rewrite
I know this is off the topic of modperl but if anyone knows of a good reference (book/webpage or whatever), I would appreciate it if you could pass those on. I am reading the URL rewriting guide at apache and I am just not finding everything I need. Any help would be greatly appreciated. Thanks, Jeff Jones
Re: [OT] mod_rewrite
http://www.engelschall.com/pw/apache/rewriteguide/ Jeff Jones wrote: I know this is off the topic of modperl but if anyone knows of a good reference (book/webpage or whatever), I would appreciate it if you could pass those on. I am reading the URL rewriting guide at apache and I am just not finding everything I need. Any help would be greatly appreciated. Thanks, Jeff Jones
[OT] mod_rewrite
It's the mod_rewrite guy again. Is there anyone who would be willing to provide some off list assistance? I just want to run a configuration by someone who knows more about this than I do and see if I am doing it right. Thanks again, Jeff Jones
Re: mod_perl, mod_rewrite, package namespace
Hi, I just wanted to let you know that (once again) re-RTFM the manual *twice* solved my muliple compilation problem. The solution is adding [PT] to the RewriteRule. RewriteRule ^/query/(.*) /query.pl?$1 [PT] -- http://www.apache.org/docs/mod/mod_rewrite.html: 'passthrough|PT' (pass through to next handler) This flag forces the rewriting engine to set the uri field of the internal request_rec structure to the value of the filename field. This flag is just a hack to be able to post-process the output of RewriteRule directives by Alias, ScriptAlias, Redirect, etc. directives from other URI-to-filename translators. A trivial example to show the semantics: If you want to rewrite /abc to /def via the rewriting engine of mod_rewrite and then /def to /ghi with mod_alias: RewriteRule ^/abc(.*) /def$1 [PT] Alias /def /ghi If you omit the PT flag then mod_rewrite will do its job fine, i.e., it rewrites uri=/abc/... to filename=/def/... as a full API-compliant URI-to-filename translator should do. Then mod_alias comes and tries to do a URI-to-filename transition which will not work. Note: You have to use this flag if you want to intermix directives of different modules which contain URL-to-filename translators. The typical example is the use of mod_alias and mod_rewrite..
mod_rewrite question..
Hi - I'm probably posting this to the incorrect list (If there is a dedicated apache list would someone please point me in it's direction.) Here's my problem - I'm trying to grab the 'id' part of a url - e.g - www.somewhere.com/id and place the val. into an environment variable - which mod_rewrite can do! Here's the httpd.conf RewriteEngine on RewriteLog mod_rewrite_log.txt RewriteLogLevel 9 RewriteRule /([^\/{1}]\w+)$/) [E=STATUS:$1] The above regex seems to work in regular code, but in httpd.conf it passes nothing to STATUS? Whereas the following code (from the rewriteguide) RewriteRule ^(.*)/S=([^/]+)/(.*)$1/$3 [E=STATUS:$2] Where the URL /foo/S=java/bar/ gets translated to /foo/bar/ and the environment variable named STATUS is set to the value "java". Is there anything obviously wrong with my regex?? Any help is appreciated, Mick
RE: mod_rewrite and Apache::Cookie
for anyone interested... I wrote a PerlTransHandler and removed mod_rewrite and am seeing the same problem as outlined below... can anyone verify this? --Geoff -Original Message- From: Geoffrey Young Sent: Wednesday, January 19, 2000 9:27 AM To: '[EMAIL PROTECTED]' Subject: mod_rewrite and Apache::Cookie hi all.. I've noticed that using mod_rewrite with Apache::Cookie exhibits odd behavior... scenario: foo.cgi uses Apache::Cookie to set a cookie mod_rewite writes all requests for index.html to /perl-bin/foo.cgi problem: access to /perl-bin/foo.cgi sets the cookie properly access to / or index.html runs foo.cgi, and attempts to set the cookie, but $cookie-bake issues the generic: Warning: something's wrong at /usr/local/apache/perl-bin/foo.cgi line 34. While I know I can use a PerlTransHandler here (and probably will now), does anyone have any ideas about this behavior? In the meanwhile, if I find out anything more while investigating, I'll post it... --Geoff
mod_rewrite and Apache::Cookie
hi all.. I've noticed that using mod_rewrite with Apache::Cookie exhibits odd behavior... scenario: foo.cgi uses Apache::Cookie to set a cookie mod_rewite writes all requests for index.html to /perl-bin/foo.cgi problem: access to /perl-bin/foo.cgi sets the cookie properly access to / or index.html runs foo.cgi, and attempts to set the cookie, but $cookie-bake issues the generic: Warning: something's wrong at /usr/local/apache/perl-bin/foo.cgi line 34. While I know I can use a PerlTransHandler here (and probably will now), does anyone have any ideas about this behavior? In the meanwhile, if I find out anything more while investigating, I'll post it... --Geoff
Re: mod_rewrite and -U Problems
No, I don't have any specific handler for /. I guess I'll keep playing around with it some more. Most of the url's will actually be in the format of 'http://www.mysite.com/path?QueryString', and I am not sure yet is -U even checks these. The docs mention it uses an internal subrequest to handle this, but I am not sure if that is anything like LWP::Simple::get() or something else entirely, meaning that it may only work on "local" url's anyway. And, I am not in the mood to go trouncing through C source to figure it out, at least not yet... Jason I don't know anything about mod_rewrite, so this is just a guess. Do you set a handler for location "/"? Maybe it's considered valid in that case. __ Get Your Private, Free Email at http://www.hotmail.com
mod_rewrite and -U Problems
I have a question about the -U test under mod_rewrite. The docs state that the test "Checks if TestString is a valid URL and accessible...". Well, the problem I am having is that if I give it a path the clearly does not exist on my system, the logs report that it does the check and returns a 200(OK). For instance, if I have a a URL that I send it: http://test.mydomain.com/click?url=hjk And then if I extract and do a -U test on 'hjk', it will report a 200 OK and try to redirect (I have indicated in my scripts to redirect only if the URL is valid, which is what I thought -U would accomplish). I have the log verbosity on 9, so I am certain that it is using _only_ the 'hjk', and not extra stuff. Specifically, the flow from the logs is: xxx.xxx.xxx.xxx - - [07/Jan/2000:16:59:13 -0500] [xxx.xxx.com/sid#8100034][rid#81a8034/initial] (5) RewriteCond URI (-U) check: path=hjk - status=200 xxx.xxx.xxx.xxx - - [07/Jan/2000:16:59:13 -0500] [xxx.xxx.com/sid#8100034][rid#81a8034/initial] (4) RewriteCond: input='hjk' pattern='-U' = matched xxx.xxx.xxx.xxx - - [07/Jan/2000:16:59:13 -0500] [xxx.xxx.com/sid#8100034][rid#81a8034/initial] (2) local path result: jh Does anyone know the inner workings of this module who could give me some insight as to why this happens? Is there another way that I can verify the validity of a URL, external or internal, from within mod_rewrite (or anything else I can use from within a configuration file)? Thanks! Jason Simms __ Get Your Private, Free Email at http://www.hotmail.com
Disregard mod_rewrite Problem...
Well, it seems that the sparse docs given to me, as well as the old server, were using mod_rewrite 1.2. I could find no information relating to backreferences within RewriteCond. Of course, when I made them go to 1.3 when I found out a newer version existed, the problem was solved. Thanks! Jason __ Get Your Private, Free Email at http://www.hotmail.com
AGAIN - mod_rewrite escaping ???
hi, I've tried : RewriteMap escape-map prg:/path/to/file/escape.pl RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} when the script is as follow for ex.: $| = 1; while() { s//_/g; print $_}; or similar it doesn't work (more precisely if I use or STDIN ?!?!) If I use this : $| = 1; print "hello"; it works only the first time ?!?! If I use : RewriteMap escape-map int:toupper RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} it works. But : RewriteMap escape-map int:escape RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} doesn't work ?!!!? What I'm doing wrong ? = iVAN [EMAIL PROTECTED] = RewriteRule ^(.*)\/index\.html$/tohtml.pl?path=$1 rewriten like this : /tohtml.pl?path=blahwlah and then in my script the result is that : QueryString("path") is equal to "blah", but not to "blahwlah". HOW to make escaping in RewriteRule ? I don't see any way to do this without recourse to an external rewrite engine. http://www.engelschall.com/pw/apache/rewriteguide/#ToC44. But, if you are already using mod_perl, you might as well ditch mod_rewrite and write your own PerlTransHandler for the URI. See Eagle book p.334, http://www.modperl.com/book/chapters/ch7.html#The_URI_Translation_Phase, better yet, buy the book and show your support.
Re: AGAIN - mod_rewrite escaping ???
Grr, this isn't a mod_perl question so I'd almost rather not respond at all... but since you don't state the version of Apache, I'll assume you are using an Apache prior to v 1.3.6 'cause that's when the escape function was implemented. Meanwhile, back at the ranch... hi, I've tried : RewriteMap escape-map prg:/path/to/file/escape.pl RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} when the script is as follow for ex.: $| = 1; while() { s//_/g; print $_}; or similar it doesn't work (more precisely if I use or STDIN ?!?!) If I use this : $| = 1; print "hello"; it works only the first time ?!?! If I use : RewriteMap escape-map int:toupper RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} it works. But : RewriteMap escape-map int:escape RewriteRule ^(.*)\/index\.html$ /tohtml.pl?path=${escape-map:$1} doesn't work ?!!!? What I'm doing wrong ? = iVAN [EMAIL PROTECTED] = RewriteRule ^(.*)\/index\.html$/tohtml.pl?path=$1 rewriten like this : /tohtml.pl?path=blahwlah and then in my script the result is that : QueryString("path") is equal to "blah", but not to "blahwlah". HOW to make escaping in RewriteRule ? I don't see any way to do this without recourse to an external rewrite engine. http://www.engelschall.com/pw/apache/rewriteguide/#ToC44. But, if you are already using mod_perl, you might as well ditch mod_rewrite and write your own PerlTransHandler for the URI. See Eagle book p.334, http://www.modperl.com/book/chapters/ch7.html#The_URI_Translation_Phase, better yet, buy the book and show your support. -- Salon Internet http://www.salon.com/ HTTP mechanic, Perl diver, Mebwaster, Some of the above Ian Kallen [EMAIL PROTECTED] / AIM: iankallen / Fax: (415) 354-3326