[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-users
Subject:    Re: [users@httpd] Setting Headers on a Redirect Scenario
From:       Daniel Ruggeri <DRuggeri () primary ! net>
Date:       2012-06-23 14:26:44
Message-ID: 4FE5D224.5050200 () primary ! net
[Download RAW message or body]

On 6/21/2012 2:21 PM, Nick Tkach wrote:
> Ok, I'm pretty sure I know the answer to this, but wanted to run it by
> people more experienced.  I have an unusual request from some business
> users.  They want to be able to request a pdf document from one site
> (which we do control) when in a web page on a *different* site (which
> we do control) *and* have it give that dialog where it prompts the
> user to save it.  This is the general idea:
>
> 1 User hits http://foo.com/sec1/blah/mydoc1.pdf
> 2 Apache for foo.com "pulls" that pdf as a request to
> http://bar.com/blah/otherstuff/mydoc1.pdf
> 3 Apache for foo.com the offers up the pdf via the original page via
> the "save" dialog
>
> The first, naive idea was to have something like this in the virtual
> host on foo.com:
>
> RewriteRule ^/sec1/(*.pdf) http://bar.com/blah/otherstuff/mydoc1.pdf
>
> <FilesMatch "/sec1/*.pdf">
>   Header always set Content-Disposition attachment
> </FilesMatch
>
>
> But that's not going to work, right?  Since Apache's going to see that
> request, redirect it to the other site, and then the *other* site is
> the thing serving up that request, so there's no way the first one can
> modify it, right?

Do you control foo.com or bar.com or both? If you only control foo, you
can not set the header. If this is a tight requirement you can't get out
of, your initial idea is close - just add the [P] flag (and load
mod_proxy). However, this will turn foo.com into a proxy to bar.com
which brings its own challenges. If you go this route you will want to
tighten up the RewriteRule pattern a bit more as well as change the
FileMatch to LocationMatch.

-- 
Daniel Ruggeri


[Attachment #3 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 6/21/2012 2:21 PM, Nick Tkach wrote:<br>
    </div>
    <blockquote
cite="mid:CADKg7ofYuVGSM8i3viwWo-23CgHsynjMFOx+JMe2TwGwZVqsSQ@mail.gmail.com"
      type="cite">
      <pre wrap="">Ok, I'm pretty sure I know the answer to this, but wanted to run \
it by people more experienced.  I have an unusual request from some business
users.  They want to be able to request a pdf document from one site
(which we do control) when in a web page on a <b class="moz-txt-star"><span \
class="moz-txt-tag">*</span>different<span class="moz-txt-tag">*</span></b> site \
(which we do control) <b class="moz-txt-star"><span \
class="moz-txt-tag">*</span>and<span class="moz-txt-tag">*</span></b> have it give \
that dialog where it prompts the user to save it.  This is the general idea:

1 User hits <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://foo.com/sec1/blah/mydoc1.pdf">http://foo.com/sec1/blah/mydoc1.pdf</a> 2 \
Apache for foo.com "pulls" that pdf as a request to <a moz-do-not-send="true" \
class="moz-txt-link-freetext" \
href="http://bar.com/blah/otherstuff/mydoc1.pdf">http://bar.com/blah/otherstuff/mydoc1.pdf</a>
 3 Apache for foo.com the offers up the pdf via the original page via
the "save" dialog

The first, naive idea was to have something like this in the virtual
host on foo.com:

RewriteRule ^/sec1/(*.pdf) <a moz-do-not-send="true" class="moz-txt-link-freetext" \
href="http://bar.com/blah/otherstuff/mydoc1.pdf">http://bar.com/blah/otherstuff/mydoc1.pdf</a>


&lt;FilesMatch "/sec1/*.pdf"&gt;
  Header always set Content-Disposition attachment
&lt;/FilesMatch


But that's not going to work, right?  Since Apache's going to see that
request, redirect it to the other site, and then the <b class="moz-txt-star"><span \
class="moz-txt-tag">*</span>other<span class="moz-txt-tag">*</span></b> site is the \
thing serving up that request, so there's no way the first one can modify it, \
right?</pre>  </blockquote>
    <br>
    Do you control foo.com or bar.com or both? If you only control foo,
    you can not set the header. If this is a tight requirement you can't
    get out of, your initial idea is close - just add the [P] flag (and
    load mod_proxy). However, this will turn foo.com into a proxy to
    bar.com which brings its own challenges. If you go this route you
    will want to tighten up the RewriteRule pattern a bit more as well
    as change the FileMatch to LocationMatch.<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel Ruggeri</pre>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic