From users-return-268527-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Sat Oct 12 15:13:32 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 58388180608 for ; Sat, 12 Oct 2019 17:13:32 +0200 (CEST) Received: (qmail 93592 invoked by uid 500); 12 Oct 2019 15:13:28 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 93576 invoked by uid 99); 12 Oct 2019 15:13:28 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 12 Oct 2019 15:13:28 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 50C941A0E28 for ; Sat, 12 Oct 2019 15:13:27 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.201 X-Spam-Level: X-Spam-Status: No, score=-0.201 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, JMQ_SPF_NEUTRAL=0.5, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=messagingengine.com Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id eRKUYk_zBtam for ; Sat, 12 Oct 2019 15:13:24 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=66.111.4.26; helo=out2-smtp.messagingengine.com; envelope-from=garret@globalmentor.com; receiver= Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id D3FF67DDCD for ; Sat, 12 Oct 2019 15:13:23 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8A971213CA for ; Sat, 12 Oct 2019 11:13:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 12 Oct 2019 11:13:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=zaWyjN1oOVbatiQOZ4nPTyLRyR7ltK2C/o9FK0t4x Ns=; b=rBxA+N2//DKEZv2lxE2NToVPRAUr5WANHmhGPtvZJVVY2cTwToFsB+SnR 7z3jEQGmcaKB9BfvEGEigZLPW7J4bqlVuf/ty1Dl+kOjDelBd3L5Q1QCXu/I6Be9 0j4tp6FM0PdXLzH6dDG9odUzwzqgRSJnNOkuqHQkQOwqNp+20GSlcY3BkK08IRnU 1vPL5kZ2PlA0jnbOQOonWudVFoU6xHvd3o/WqjtutJN5figBtQQw21RmdFclOTdI eVE0EDIDAIfhWZygX7aC8usgmRrHRpiGSNxB9WzcG1pOTJZ+sVh3fuFMWBXYysHt 00GC8OUPib65HZqizHLLQlfig07Fw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieejgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuhffvfhhokffffgggjggtgfesthekredttdefjeenucfhrhhomhepifgrrhhr vghtucghihhlshhonhcuoehgrghrrhgvthesghhlohgsrghlmhgvnhhtohhrrdgtohhmqe enucfkphepudekledruddvvddrgeelrdekudenucfrrghrrghmpehmrghilhhfrhhomhep ghgrrhhrvghtsehglhhosggrlhhmvghnthhorhdrtghomhenucevlhhushhtvghrufhiii gvpedt X-ME-Proxy: Received: from [192.168.1.194] (unknown [189.122.49.81]) by mail.messagingengine.com (Postfix) with ESMTPA id 02BE6D6005E for ; Sat, 12 Oct 2019 11:13:15 -0400 (EDT) Subject: Re: efficient redirect map with embedded Tomcat From: Garret Wilson To: Tomcat Users List References: <720d1edd-6dc6-dec1-32a7-ac99a01b159b@globalmentor.com> Organization: GlobalMentor, Inc. Message-ID: Date: Sat, 12 Oct 2019 12:13:13 -0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <720d1edd-6dc6-dec1-32a7-ac99a01b159b@globalmentor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Could somebody at least point me to the best place to wire in site-level per-resource redirects in embedded Tomcat? I can create a solution, I just need to know where it is best to start. Thanks, Garret On 10/11/2019 11:06 AM, Garret Wilson wrote: > This is a question for Tomcat experts before I get started > implementing a new feature. > > Let's say I'm embedding Tomcat to serve static files. At the time of > creation I know that certain paths, such as `foo/bar.txt`, should > redirect to other paths, such as `some/other.txt`. What's the best way > to configure Tomcat to do those redirects? I'm comfortable with > extending the source code. > > Here are a couple of ideas that come to mind: > >  * I could create a redirect servlet and map different instances of it >    to different targets in the context when I configure everything. But >    in Tomcat's routing engine, is the most efficient way to do things? >    (I assume that the servlet mappings can be placed "over" the default >    servlet's path space, that is, cherry-pick paths for redirection, >    falling back to the default file-serving servlet for non-redirect >    paths.) >  * I thought of patching into the default file servlet, overriding >    `org.apache.catalina.WebResource`, and creating virtual >    `RedirectResource` resources that don't correspond to any physical >    file. However it's not obvious to me where I would create a >    redirect. Maybe throw some redirect exception inside >    `WebResource.getInputStream()`? (This is probably not correct. I'm >    just brainstorming. The idea is sound if I knew where to put it.) >  * Should I install a configured rewrite valve when I'm setting up >    embedded Tomcat? >  * Is there some other routing logic in Tomcat I could tap into most >    efficiently, providing a known set of redirects? > > Thanks for any guidance. I'm want to figure out the best way to attack > this before getting very deep in an implementation. > > Garret > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org