Environment variable to notify it's a SPDY request and server push?

83 views
Skip to first unread message

Leandro López

unread,
Apr 20, 2012, 3:57:13 PM4/20/12
to mod-spdy...@googlegroups.com
Hi list,

First of all I would like to congratulate to the SPDY & mod_spdy team for such a great work on this.

I'm playing with mod_spdy and so far I haven't found any trouble on the road, again, great work!

My current setup is Apache as a static resources server and proxy server for dynamic pages, and I was wondering if it's possible to indicate through environments variables or something like that when the request is being served as SPDY or HTTPS.

Also I was wondering if there's any plan to add some mechanism to indicate which resources could be served via server push.

Thank you for your time,

Leandro
(inkel)

Matthew Steele

unread,
Apr 20, 2012, 4:38:19 PM4/20/12
to mod-spdy...@googlegroups.com
On Fri, Apr 20, 2012 at 3:57 PM, Leandro López <inke...@gmail.com> wrote:
> I'm playing with mod_spdy and so far I haven't found any trouble on the
> road, again, great work!

Glad to hear it's working well for you!

> My current setup is Apache as a static resources server and proxy server for
> dynamic pages, and I was wondering if it's possible to indicate through
> environments variables or something like that when the request is being
> served as SPDY or HTTPS.

mod_spdy does this already (I guess that's not documented at the
moment; I'd better fix that). For requests served over SPDY, mod_spdy
sets the "SPDY_VERSION" environment variable to the SPDY version
number being used (for now, that's always "2", but in the future
mod_spdy will support later SPDY versions). For non-SPDY requests,
that environment variable will be empty. So if all you want to know
is whether the request is SPDY or not, just check if the SPDY_VERSION
environment variable is non-empty.

(There's also an inter-module function to check if SPDY is in use, for
authors of other Apache modules.)

> Also I was wondering if there's any plan to add some mechanism to indicate
> which resources could be served via server push.

Yes, server push is definitely on the to-do list for the near future
(although it's not yet supported in the current release). Most likely
that would be triggered by setting a special response header with the
URL(s) to be pushed (or by calling an inter-module function). Would
that work well for you? I'm definitely open to suggestions here.

Cheers,
-Matthew

Leandro López (inkel)

unread,
Apr 20, 2012, 4:47:19 PM4/20/12
to mod-spdy...@googlegroups.com
On Fri, Apr 20, 2012 at 5:38 PM, Matthew Steele <mdst...@google.com> wrote:
>> My current setup is Apache as a static resources server and proxy server for
>> dynamic pages, and I was wondering if it's possible to indicate through
>> environments variables or something like that when the request is being
>> served as SPDY or HTTPS.
>
> mod_spdy does this already (I guess that's not documented at the
> moment; I'd better fix that).  For requests served over SPDY, mod_spdy
> sets the "SPDY_VERSION" environment variable to the SPDY version
> number being used (for now, that's always "2", but in the future
> mod_spdy will support later SPDY versions).  For non-SPDY requests,
> that environment variable will be empty.  So if all you want to know
> is whether the request is SPDY or not, just check if the SPDY_VERSION
> environment variable is non-empty.

Mmm... I'm not seeing it, though I'm seeing a SPDY session on
chrome://net-internals/#spdy

My config is Apache => Unicorn => Cuba app, which it's the same as
saying a simple Ruby's Rack application, and I've a special path that
prints the current request environment and SPDY_VERSION is not
present.

Perhaps it's because I'm using the .deb version? I'll try compiling my
own version of the extension and I'll let you know.

>> Also I was wondering if there's any plan to add some mechanism to indicate
>> which resources could be served via server push.
>
> Yes, server push is definitely on the to-do list for the near future
> (although it's not yet supported in the current release).  Most likely
> that would be triggered by setting a special response header with the
> URL(s) to be pushed (or by calling an inter-module function).  Would
> that work well for you?  I'm definitely open to suggestions here.

That is exactly what I had in mind :)

Something like setting a response header of X-SPDY-Push:
"https://fqdn.to/resource/1 https://fqdn.to/resource/2
https://fqdn.to/resource/etc" ? That'd be the easier way server push
even from CGI scripts.

--
Leandro
(inkel)

Leandro López (inkel)

unread,
Apr 20, 2012, 5:06:34 PM4/20/12
to mod-spdy...@googlegroups.com
On Fri, Apr 20, 2012 at 5:47 PM, Leandro López (inkel)
<inke...@gmail.com> wrote:
> Perhaps it's because I'm using the .deb version? I'll try compiling my
> own version of the extension and I'll let you know.

No, I compile a new mod_spdy version from source and I'm still not
getting SPDY_VERSION.

Anything else I can do to give you more information?

--
Leandro
(inkel)

Matthew Steele

unread,
Apr 20, 2012, 5:36:53 PM4/20/12
to mod-spdy...@googlegroups.com
Hmm. I wasn't previously familiar with Unicorn, so I'm looking it up
now and trying to understand how that setup works. Is it the case
that you have Apache set up with mod_spdy and mod_proxy, and are
proxying requests from Apache to Unicorn, or am I misunderstanding?
If that is in fact the case, then the environment variable set in
Apache isn't going to make its way over to Unicorn, and hence isn't
going to be visible to your app. Does that sound right, or am I
confused?

Maybe I should see if I can get mod_spdy to add a special header to
outgoing requests sent by mod_proxy to indicate that the original
request was sent via SPDY. Would that help?

On Fri, Apr 20, 2012 at 5:06 PM, Leandro López (inkel)

Leandro López (inkel)

unread,
Apr 20, 2012, 5:43:06 PM4/20/12
to mod-spdy...@googlegroups.com


On Apr 20, 2012 6:36 PM, "Matthew Steele" <mdst...@google.com> wrote:
>
> Hmm.  I wasn't previously familiar with Unicorn, so I'm looking it up
> now and trying to understand how that setup works.  Is it the case
> that you have Apache set up with mod_spdy and mod_proxy, and are
> proxying requests from Apache to Unicorn, or am I misunderstanding?
> If that is in fact the case, then the environment variable set in
> Apache isn't going to make its way over to Unicorn, and hence isn't
> going to be visible to your app.  Does that sound right, or am I
> confused?
>

That's right, Apache is in front of Unicorn and proxies requests to it.

> Maybe I should see if I can get mod_spdy to add a special header to
> outgoing requests sent by mod_proxy to indicate that the original
> request was sent via SPDY.  Would that help?

That would be wonderful, and it'll be useful to any other proxied environment I guess.

Thanks!

inkel

Leandro López (inkel)

unread,
Apr 21, 2012, 10:47:47 AM4/21/12
to mod-spdy...@googlegroups.com
Matthew:

I've fixed this, it was so simple that I feel a little dumb now :P

RequestHeader set SPDY "SPDY v%{SPDY_VERSION}e" env=SPDY_VERSION

This adds HTTP_SPDY="SPDY v2" to the request environment received by
the proxy if and only if SPDY_VERSION is present.

--
Leandro
(inkel)
Reply all
Reply to author
Forward
0 new messages