<?xml version="1.0" encoding="UTF-8" standalone="yes"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-us"><id>https://blog.pgxn.org/tags/plack/</id><title>Plack</title><updated>2010-10-11T15:00:29Z</updated><link rel="self" type="application/atom+xml" href="https://blog.pgxn.org/tags/plack/feed.xml"/><link rel="alternate" type="text/html" href="https://blog.pgxn.org/tags/plack/"/><author><name>The PGXN Maintainers</name></author><generator uri="https://gohugo.io/" version="0.167.0">Hugo</generator><entry><id>https://blog.pgxn.org/post/1291485816</id><title type="html">How Can I Detect a Proxied SSL Request?</title><link rel="alternate" type="text/html" href="https://blog.pgxn.org/2010/how-can-i-detect-a-proxied-ssl-request/"/><updated>2026-10-07T16:13:48Z</updated><published>2010-10-11T15:00:29Z</published><author><name>David E. Wheeler</name></author><category scheme="https://blog.pgxn.org/tags" term="mod_proxy" label="mod_proxy"/><category scheme="https://blog.pgxn.org/tags" term="mod_ssl" label="mod_ssl"/><category scheme="https://blog.pgxn.org/tags" term="ssl" label="SSL"/><category scheme="https://blog.pgxn.org/tags" term="proxy" label="Proxy"/><category scheme="https://blog.pgxn.org/tags" term="uri" label="URI"/><category scheme="https://blog.pgxn.org/tags" term="apache" label="Apache"/><category scheme="https://blog.pgxn.org/tags" term="plack" label="Plack"/><category scheme="https://blog.pgxn.org/tags" term="request" label="Request"/><summary type="html"><![CDATA[I&rsquo;ve been thinking about how best to create two sections of the PGXN Manager
site, one that requires authentication and is on SSL and one that&rsquo;s public. So
far, I&rsquo;ve just had all the authenticated stuff go to /auth (because I&rsquo;m using
basic auth), but what I want to do now is require authentication if the
connection is via SSL. However, using a reverse proxy with mod_proxy to map to
the PGXN Manger Plack app running on an internal port, I&rsquo;ve found no
environment variables passed through that would allow me, in code, to
determine whether a request is via a proxied SSL or non-SSL connection. Most
irritating.]]></summary><content type="html" xml:base="https://blog.pgxn.org/" xml:space="preserve"><![CDATA[<p>I&rsquo;ve been thinking about how best to create two sections of the PGXN Manager
site, one that requires authentication and is on SSL and one that&rsquo;s public. So
far, I&rsquo;ve just had all the authenticated stuff go to /auth (because I&rsquo;m using
basic auth), but what I want to do now is require authentication if the
connection is via SSL. However, using a reverse proxy with mod_proxy to map to
the PGXN Manger Plack app running on an internal port, I&rsquo;ve found no
environment variables passed through that would allow me, in code, to
determine whether a request is via a proxied SSL or non-SSL connection. Most
irritating.</p>
<p>So tell me what you think about the alternative plan I&rsquo;ve come up with.</p>
<p>I&rsquo;ll have two plack apps, one mapped to /auth and one mapped to /no-auth. The
former will require authentication and the latter will not. They&rsquo;ll have
separate dispatch tables, of course. Then I&rsquo;ll have the SSL site proxied to
/auth and the non-SSL site proxied to /no-auth. Makes sense, right?</p>
<p>The only hangup I can see (though maybe you can see others?) is that my
current method of generating URIs knows nothing about proxies. So If I link to
/auth/account, when requests come through the proxy, it should actually create
a link to /account. Does it make sense to use relative links instead of
absolute links for all links to avoid this issue? I think it might be kind of
annoying, because not all the code is aware of the current URI, though there
are ways to deal with that.</p>
<p>Thoughts?</p>
<p>I guess I could stick with absolute URLs, and then have the <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Request.pm#L14"><code>uri_for</code></a> use
<code>$req−&gt;uri−&gt;path</code> for a proxied request and <code>$req−&gt;path_info</code> for a
non-proxied request.</p>
<p>Sure would be nice if there was some way to tell from the environment that a
request was forwarded from an SSL connection, though. Alas, there are only
three extra environment variable set by the proxy server:</p>
<ul>
<li>HTTP_X_FORWARDED_FOR</li>
<li>HTTP_X_FORWARDED_HOST</li>
<li>HTTP_X_FORWARDED_SERVER</li>
</ul>
<p>No HTTP_X_FORWARDED_PORT or HTTP_X_FORWARDED_SSL or SSL_ENABLED or anything
like that. Maybe I&rsquo;m missing something in my reading of the <a href="https://httpd.apache.org/docs/2.2/mod/mod_proxy.html">mod_proxy
documentation</a>?</p>
]]></content></entry><entry><id>https://blog.pgxn.org/post/1138292188</id><title type="html">Architecture, New Extension JSON Format</title><link rel="alternate" type="text/html" href="https://blog.pgxn.org/2010/arch-and-extension-json/"/><updated>2026-10-07T16:13:48Z</updated><published>2010-09-17T17:33:00Z</published><author><name>David E. Wheeler</name></author><category scheme="https://blog.pgxn.org/tags" term="pgxn-manager" label="PGXN Manager"/><category scheme="https://blog.pgxn.org/tags" term="pgxnmanager" label="PGXN::Manager"/><category scheme="https://blog.pgxn.org/tags" term="plack" label="Plack"/><category scheme="https://blog.pgxn.org/tags" term="catalyst" label="Catalyst"/><category scheme="https://blog.pgxn.org/tags" term="dancer" label="Dancer"/><category scheme="https://blog.pgxn.org/tags" term="jifty" label="Jifty"/><category scheme="https://blog.pgxn.org/tags" term="extension" label="Extension"/><category scheme="https://blog.pgxn.org/tags" term="metadata" label="Metadata"/><summary type="html"><![CDATA[<p>I&rsquo;m making good progress on <a href="https://github.com/theory/pgxn-manager">PGXN Manager</a>. Hopefully I can start alpha
testing it next week. As I mentioned <a href="https://blog.pgxn.org/post/1082188310/db-status-update">previously</a>, I had estimated 40 hours of
work to create it, but was hoping to get it done in around 30 (because I spent
10 extra hours on the database design). So far I&rsquo;m at 23 hours, so it&rsquo;s
looking pretty good.</p>
<p>Architecturally, I&rsquo;ve gone for a very minimal <a href="https://plackperl.org/">Plack</a>-based app. No
<a href="https://www.catalystframework.org/">Catalyst</a>, <a href="https://jifty.org/">Jifty</a>, or even <a href="https://perldancer.org/">Dancer</a>. Just a very simple <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Router.pm">Plack app</a> that
uses <a href="https://search.cpan.org/perldoc?Router::Simple::Sinatraish">Router::Simple::Sinatraish</a> to route URIs to the appropriate
<a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Controller.pm">controller</a> actions (which are just class methods). The controller just
dispatches to <a href="https://search.cpan.org/perldoc?Template::Declare">Template::Declare</a>-based <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Templates.pm">templates</a> for the HTML rendering. I
guess I&rsquo;ve kind of created my own framework here, but really, there ain&rsquo;t much
to it. This app is simple enough that I couldn&rsquo;t see the use of adding all the
overhead of a framework.</p>]]></summary><content type="html" xml:base="https://blog.pgxn.org/" xml:space="preserve"><![CDATA[<p>I&rsquo;m making good progress on <a href="https://github.com/theory/pgxn-manager">PGXN Manager</a>. Hopefully I can start alpha
testing it next week. As I mentioned <a href="https://blog.pgxn.org/post/1082188310/db-status-update">previously</a>, I had estimated 40 hours of
work to create it, but was hoping to get it done in around 30 (because I spent
10 extra hours on the database design). So far I&rsquo;m at 23 hours, so it&rsquo;s
looking pretty good.</p>
<p>Architecturally, I&rsquo;ve gone for a very minimal <a href="https://plackperl.org/">Plack</a>-based app. No
<a href="https://www.catalystframework.org/">Catalyst</a>, <a href="https://jifty.org/">Jifty</a>, or even <a href="https://perldancer.org/">Dancer</a>. Just a very simple <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Router.pm">Plack app</a> that
uses <a href="https://search.cpan.org/perldoc?Router::Simple::Sinatraish">Router::Simple::Sinatraish</a> to route URIs to the appropriate
<a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Controller.pm">controller</a> actions (which are just class methods). The controller just
dispatches to <a href="https://search.cpan.org/perldoc?Template::Declare">Template::Declare</a>-based <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Templates.pm">templates</a> for the HTML rendering. I
guess I&rsquo;ve kind of created my own framework here, but really, there ain&rsquo;t much
to it. This app is simple enough that I couldn&rsquo;t see the use of adding all the
overhead of a framework.</p>
<p>Meanwhile, I&rsquo;ve been hacking on the <a href="https://github.com/theory/pgxn-manager/blob/master/lib/PGXN/Manager/Distribution.pm">distributon class</a>. This will be the core
class of the app. It takes a <a href="https://search.cpan.org/perldoc?Plack::Request::Upload">Plack upload</a> object and a username and does all
the rest, analyzing an uploaded archive, normalizing it if necessary,
registering it with the database, and indexing it by updating all the
appropriate JSON files on the mirrors. It&rsquo;s nearly finished, but I have one
other thing to do in the database, first.</p>
<p>In my <a href="https://blog.pgxn.org/post/1082188310/db-status-update">last update</a>, I asked for advice on whether or not PGXN
should allow an extension with the same version number to appear in multiple
distributions. And thanks to a <a href="https://blog.pgxn.org/post/1082188310/db-status-update#comment-75931198">comment from Aristotle</a>, I&rsquo;m changing it to
allow that. But it also means that my <a href="https://blog.pgxn.org/post/988613682/restful-directory#extension-json">original extension json spec</a> needs to
change.</p>
<p>Here&rsquo;s an example of what I&rsquo;m thinking. Say that there are three versions of
an extension named &ldquo;trip&rdquo;, and that they appear in distributions as follows:</p>
<pre tabindex="0"><code>trip 0.2.6
  pair-0.3.0
<p>trip 0.2.5
trip-0.2.2
pair-0.2.2rc
pair-0.2.1
trip-0.1.1</p>
<p>trip 0.2.4
pair-0.1.1rc
pair-0.1.0
</code></pre><p>So sometimes it’s in the “trip” distribution and other times it’s in the
“pair” distribution. My thought is that, for a given version, it would list
the distributions it’s in in reverse chronological order (by upload date). So
the format would be:</p></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&#34;latest&#34;</span><span class="p">:</span> <span class="s2">&#34;stable&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&#34;stable&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.3.0&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&#34;testing&#34;</span><span class="p">:</span> <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.2.2rc&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&#34;distributions&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;0.2.6&#34;</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.3.0&#34;</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl">      <span class="p">],</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;0.2.5&#34;</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;trip&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.2.2&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.2.2rc&#34;</span><span class="p">,</span> <span class="nt">&#34;status&#34;</span><span class="p">:</span> <span class="s2">&#34;testing&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.2.1&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;trip&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.1.1&#34;</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl">      <span class="p">],</span>
</span></span><span class="line"><span class="cl">      <span class="nt">&#34;0.2.4&#34;</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.1.1rc&#34;</span><span class="p">,</span> <span class="nt">&#34;status&#34;</span><span class="p">:</span> <span class="s2">&#34;testing&#34;</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl">         <span class="p">{</span> <span class="nt">&#34;dist&#34;</span><span class="p">:</span> <span class="s2">&#34;pair&#34;</span><span class="p">,</span> <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;0.1.0&#34;</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl">      <span class="p">]</span>
</span></span><span class="line"><span class="cl">   <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>This way, every distribution it&rsquo;s included in is listed, and clients can
quickly tell where to find the latest stable, testing, and unstable versions,
and which of those is the most recent. This is a bit more convoluted than <a href="https://blog.pgxn.org/post/988613682/restful-directory#extension-json">the
original</a>, but I think is a good choice, in that
it&rsquo;s comprehensive but also easy to figure out what&rsquo;s the latest.</p>
<p>Unless you can think of a better format, this is what I&rsquo;m going with.
Comments?</p>
<p>Look for a post next week announcing an alpha program!</p>
]]></content></entry></feed>