<?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/mod_proxy/</id><title>Mod_proxy</title><updated>2010-10-11T15:00:29Z</updated><link rel="self" type="application/atom+xml" href="https://blog.pgxn.org/tags/mod_proxy/feed.xml"/><link rel="alternate" type="text/html" href="https://blog.pgxn.org/tags/mod_proxy/"/><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></feed>