Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0B7EEDAC4 for ; Fri, 17 Aug 2012 14:43:25 +0000 (UTC) Received: (qmail 50607 invoked by uid 500); 17 Aug 2012 14:43:24 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 50580 invoked by uid 500); 17 Aug 2012 14:43:24 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 50572 invoked by uid 99); 17 Aug 2012 14:43:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 14:43:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sorinm@gmail.com designates 209.85.215.173 as permitted sender) Received: from [209.85.215.173] (HELO mail-ey0-f173.google.com) (209.85.215.173) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Aug 2012 14:43:18 +0000 Received: by eaac13 with SMTP id c13so1829124eaa.18 for ; Fri, 17 Aug 2012 07:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=IkLUUpkc0aniClnS6db3V+RPWE4KwqE8OZqvsA4U0u0=; b=I1Kh0vWiKyEelVUvzedKhPGy/80hUUKVjPeDDJrKDiNnJoL9dagLg0em1lwpW8D1/2 LJncPvrnviICuTHyhY3Xz+UMypfabrsmdd85d6JVb6e1wr+/kHjAnyH+i4uPjvXe4dUp UfNNBr7YZJ8yNB9rC97BrdecADYEj4dW18Hrch6xFX6foMDyFKsPN2iqUSP4PfCuggeE cUacr9k3sDS8s0nVtl8TLKB5DteBonPHdD6OCcGitr1AV19kodCafbz8VGORFrYb0Clq JxViSBuwmjcN8SJlzXBGX/RouGYSTQPz4Y6CAWH2J1ykuqwuIX6Nvmh11d/EX1n8S1Yj 0AmQ== Received: by 10.14.210.132 with SMTP id u4mr6657289eeo.6.1345214577283; Fri, 17 Aug 2012 07:42:57 -0700 (PDT) Received: from ?IPv6:2a01:c9c0:a1:15:213:72ff:fe38:2e23? ([2a01:c9c0:a1:15:213:72ff:fe38:2e23]) by mx.google.com with ESMTPS id c6sm20670621eep.7.2012.08.17.07.42.55 (version=SSLv3 cipher=OTHER); Fri, 17 Aug 2012 07:42:56 -0700 (PDT) Message-ID: <502E586D.1050807@gmail.com> Date: Fri, 17 Aug 2012 16:42:53 +0200 From: Sorin Manolache User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: forward request with proxy_http in custom module References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On 2012-08-17 16:25, nik600 wrote: > Dear all > > i'm trying to code a custom module that will implement some logic this > is the concept of the module: > > ********************************* > > /* > * some stuff... > */ > if(condition){ > > /*return a custom result*/ > > return OK; > > }else{ > /*forward the request to another server*/ > > r->filename = "proxy:http://www.google.it/"; > r->proxyreq = PROXYREQ_PROXY; > r->handler = "proxy-server"; > > return OK; > } > ********************************* > > But it seems that when i go into the else condition the proxy request > isn't handled. > > proxy and proxy_http are enabled and correctly working. > > Is this code correct to forward a request and make my module working > as a proxy_http ? Try if (condition) { ... return OK; } else { return DECLINED; } and make sure your handler runs before mod_proxy's: static const char *succ[] = {"mod_proxy.c", NULL}; ap_hook_handler(&your_handler, NULL, succ, APR_HOOK_MIDDLE); Then put a ProxyPass in your conf: ProxyPass http://www.google.it/ keepalive=On Also make sure you do not check on r->handler. Even if you set "SetHandler your_handler", ProxyPass will overwrite it with "proxy-server". Sorin > > Thanks in advance >