Permalink
Browse files

add reverse proxy docs. Closes #31

  • Loading branch information...
1 parent 7d9da8e commit 3b4a7a4da95db38abf0c25f1b60124f57b187798 @tj tj committed Oct 5, 2012
Showing with 36 additions and 3 deletions.
  1. +2 −1 en/guide/index.jade
  2. +1 −0 en/guide/menu.jade
  3. +20 −0 en/guide/proxies.jade
  4. +13 −2 guide.html
View
@@ -1,4 +1,5 @@
include intro
include executable
include error-handling
-include users-online
+include users-online
+include proxies
View
@@ -4,3 +4,4 @@ ul#menu
li: a(href='#executable') express(1) executable
li: a(href='#error-handling') Error handling
li: a(href='#users-online') Users online count
+ li: a(href='#proxies') Express behind proxies
View
@@ -0,0 +1,20 @@
+section
+ h3(id='proxies') Express behind proxies
+
+ p.
+ Using Express behind a reverse proxy such as Varnish or Nginx
+ is trivial, however it does require configuration. By enabling the "trust proxy" setting via
+ <code>app.enable('trust proxy')</code>, Express will have knowledge that
+ it's sitting behind a proxy and that the <code>X-Forwarded-*</code> header
+ fields may be trusted, which otherwise may be easily spoofed.
+
+ p.
+ Enabling this setting has several subtle effects. The first of which is
+ that <code>X-Forwarded-Proto</code> may be set by the reverse proxy to
+ tell the app that it is https or simply http. This value is reflected
+ by <a href="#req.protocol">req.protocol</a>.
+
+ p.
+ The second change this makes is the <a href="#req.ip">req.ip</a>
+ and <a href="#req.ips">req.ips</a> values will be populated with
+ <code>X-Forwarded-For</code>'s list of addresses.
View
@@ -1,5 +1,5 @@
<!DOCTYPE html><html><head><title>Express - guide</title><link rel="stylesheet" href="style.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&amp;subset=latin,latin-ext"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script><script src="app.js"></script><script src="retina.js"></script></head><body class="inner"><div class="bar"></div><section id="content"><header><section id="logo"><span class="express">express<em>3.0.0</em></span><span class="description">
-web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class="active"> Guide</a><a href="/applications.html" class=""> Applications</a><a href="/community.html" class=""> Community</a><a href="/faq.html" class=""> FAQ</a></nav></header><ul id="menu"><li><ul><li><a href="#intro">Getting started</a></li><li><a href="#executable">express(1) executable</a></li><li><a href="#error-handling">Error handling</a></li><li><a href="#users-online">Users online count</a></li></ul></li></ul><section><h3 id="intro">Getting started</h3><p>With node installed (<a href="http://nodejs.org/#download">download</a>),
+web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class="active"> Guide</a><a href="/applications.html" class=""> Applications</a><a href="/community.html" class=""> Community</a><a href="/faq.html" class=""> FAQ</a></nav></header><ul id="menu"><li><ul><li><a href="#intro">Getting started</a></li><li><a href="#executable">express(1) executable</a></li><li><a href="#error-handling">Error handling</a></li><li><a href="#users-online">Users online count</a></li><li><a href="#proxies">Express behind proxies</a></li></ul></li></ul><section><h3 id="intro">Getting started</h3><p>With node installed (<a href="http://nodejs.org/#download">download</a>),
get your first application started by creating a directory somewhere
on your machine:
</p><pre class="js"><code>$ mkdir hello-world
@@ -206,7 +206,18 @@
res.send(req.online.length + ' users online');
});
-app.listen(3000);</code></pre></section></section><script>var _gaq = _gaq || [];
+app.listen(3000);</code></pre></section><section><h3 id="proxies">Express behind proxies</h3><p>Using Express behind a reverse proxy such as Varnish or Nginx
+is trivial, however it does require configuration. By enabling the "trust proxy" setting via
+<code>app.enable('trust proxy')</code>, Express will have knowledge that
+it's sitting behind a proxy and that the <code>X-Forwarded-*</code> header
+fields may be trusted, which otherwise may be easily spoofed.
+</p><p>Enabling this setting has several subtle effects. The first of which is
+that <code>X-Forwarded-Proto</code> may be set by the reverse proxy to
+tell the app that it is https or simply http. This value is reflected
+by <a href="#req.protocol">req.protocol</a>.
+</p><p>The second change this makes is the <a href="#req.ip">req.ip</a>
+and <a href="#req.ips">req.ips</a> values will be populated with
+<code>X-Forwarded-For</code>'s list of addresses. </p></section></section><script>var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25235225-1']);
_gaq.push(['_trackPageview']);

0 comments on commit 3b4a7a4

Please sign in to comment.