<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Nicolai Kamenzky</title>
    <description>MEAN stack enthusiast</description>
    <link>https://analognico.silvrback.com/feed</link>
    <atom:link href="https://analognico.silvrback.com/feed" rel="self" type="application/rss+xml"/>
    <category domain="analognico.silvrback.com">Content Management/Blog</category>
    <language>en-us</language>
      <pubDate>Thu, 05 Mar 2015 05:07:34 -1100</pubDate>
    <managingEditor>nicolai.kamenzky@testrails.org (Nicolai Kamenzky)</managingEditor>
      <item>
        <guid>http://analog-ni.co/all-in-on-ssl-on-modulus#12615</guid>
          <pubDate>Thu, 05 Mar 2015 05:07:34 -1100</pubDate>
        <link>http://analog-ni.co/all-in-on-ssl-on-modulus</link>
        <title>All-in on SSL on Modulus</title>
        <description></description>
        <content:encoded><![CDATA[<p>I am hosting my node.js + Express app <a href="https://morningfa.me">https://morningfa.me</a> on <a href="https://modulus.io">Modulus</a> and without question everything must go through https. This is the full picture of how I set it up.</p>

<ol>
<li><p><strong>Redirecting to HTTPS</strong></p>

<p>In the admin panel I activated Modulus&#39; redirection feature so that any http requests will be redirected.<br>
<img alt="Silvrback blog image" src="https://silvrback.s3.amazonaws.com/uploads/7972b209-934d-4151-a4ee-b4fb159471e5/Screen%20Shot%202015-03-05%20at%2009.55.18_large.png" /></p>

<p>Since Modulus has a proxy that does SSL termination my app can still <code>require(http)</code>. The https module is not needed.</p></li>
<li><p><strong>Getting my own SSL certificate</strong></p>

<p>After the first step I couldn&#39;t access my domain morningfa.me without a security violation in the browser anymore. I had to buy a SSL certificate for the domain &quot;<a href="http://www.morningfa.me">www.morningfa.me</a>&quot;. This is automatically also valid for &quot;morningfa.me&quot;.</p>

<p>Modulus has a <a href="http://help.modulus.io/customer/portal/articles/1701165-ssl-setup-guide">great guide</a> on how to buy and install the certificate. After following those steps my configuration looked like this:</p>

<p><img alt="Silvrback blog image" src="https://silvrback.s3.amazonaws.com/uploads/6b7d4543-6697-4637-af77-9f089e316e04/Screen%20Shot%202015-03-05%20at%2010.06.47_large.png" /></p>

<p>BTW, I pasted the same private key and certificate for both entries in the custom SSL section. To test if everything is properly configured I used <a href="https://ssltools.websecurity.symantec.com/checker/views/certCheck.jsp">Symantec&#39;s tester</a> which actually helps you to fix problems and afterwards I used <a href="https://www.ssllabs.com/ssltest/">Qualys SLL Labs</a> for a more advanced look.</p></li>
<li><p><strong>Redirecting WWW to non-WWW</strong></p>

<p>I prefer to use &quot;morningfa.me&quot; instead of &quot;<a href="http://www.morningfa.me">www.morningfa.me</a>&quot; so I needed a redirection mechanism. The other way around would be easy but this is actually a little tough due to limitations of the DNS entries.</p>

<p>I configured two DNS A-record entries in my domain settings. I registered my domain with <a href="https://www.bluehost.com">Bluehost</a>  where these entries look like this:</p>

<p><img alt="Silvrback blog image" src="https://silvrback.s3.amazonaws.com/uploads/7488e1a6-bcfd-44c0-9959-23a605146ece/Screen%20Shot%202015-03-05%20at%2010.28.02_large.png" /></p>

<p>Depending on where you bought your domain your configuration may look a little different. Anyway, the IPs you need to use are listed <a href="http://help.modulus.io/customer/portal/articles/1700863-custom-domains">here</a>.</p>

<p>At this point both &quot;morningfa.me&quot; and &quot;<a href="http://www.morningfa.me">www.morningfa.me</a>&quot; are forwarded to the Modulus servers and don&#39;t show security violations in the browser anymore. To finally redirect www to non-www URLs I added a small Express middleware:</p>
<div class="highlight"><pre><span></span><span class="nx">app</span><span class="p">.</span><span class="nx">use</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">req</span><span class="p">,</span> <span class="nx">res</span><span class="p">,</span> <span class="nx">next</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">if</span> <span class="p">(</span><span class="nx">req</span><span class="p">.</span><span class="nx">headers</span><span class="p">.</span><span class="nx">host</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/^www\./i</span><span class="p">))</span> <span class="p">{</span>
        <span class="nx">res</span><span class="p">.</span><span class="nx">redirect</span><span class="p">(</span><span class="mi">301</span><span class="p">,</span>
            <span class="s1">&#39;https://&#39;</span> <span class="o">+</span> <span class="nx">req</span><span class="p">.</span><span class="nx">headers</span><span class="p">.</span><span class="nx">host</span><span class="p">.</span><span class="nx">substr</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span> <span class="o">+</span> <span class="nx">req</span><span class="p">.</span><span class="nx">url</span>
        <span class="p">);</span>
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
        <span class="k">return</span> <span class="nx">next</span><span class="p">();</span>
    <span class="p">}</span>
<span class="p">});</span>
</pre></div></li>
<li><p><strong>Securing the Session Cookie</strong></p>

<p>I use <a href="https://www.npmjs.com/package/express-session">Express-Session</a> that sends a cookie to the browser. Since I am only using HTTPS I can improve the security by marking the cookie as secure. This way the browser will only send the cookie over the wire when a secure connection is made.</p></li>
</ol>

<p>The session parameters needed to use a secure cookie on Modulus are the following:</p>

<p>``` js<br>
    app.use(session({<br>
        // ...<br>
        cookie: {<br>
            // ...<br>
            secure: true<br>
        },<br>
        proxy: true<br>
    }));</p>

<p>That&#39;s it. Hope it helps. And if you got stuck somewhere let me know in the comments and I will fill in the blanks.</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://analog-ni.co/my-css-autoprefixer-settings-for-ie9-and-up#11666</guid>
          <pubDate>Sat, 24 Jan 2015 13:56:29 -1100</pubDate>
        <link>http://analog-ni.co/my-css-autoprefixer-settings-for-ie9-and-up</link>
        <title>My CSS-Autoprefixer Settings for IE9 and Up</title>
        <description></description>
        <content:encoded><![CDATA[<p>Chances are, you use the <code>border-box</code> default, too:</p>
<div class="highlight"><pre><span></span><span class="o">*,</span> <span class="o">*</span><span class="p">:</span><span class="nd">before</span><span class="o">,</span> <span class="o">*</span><span class="p">:</span><span class="nd">after</span> <span class="p">{</span>
    <span class="k">box-sizing</span><span class="p">:</span> <span class="kc">border-box</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>Today I stumbled upon <a href="http://caniuse.com/#search=box-sizing">the fact</a> that many still kinda recent browser versions need prefixing for that. What I want is:</p>
<div class="highlight"><pre><span></span><span class="o">*,</span> <span class="o">*</span><span class="p">:</span><span class="nd">before</span><span class="o">,</span> <span class="o">*</span><span class="p">:</span><span class="nd">after</span> <span class="p">{</span>
    <span class="kp">-webkit-</span><span class="k">box-sizing</span><span class="p">:</span> <span class="kc">border-box</span><span class="p">;</span>
       <span class="kp">-moz-</span><span class="k">box-sizing</span><span class="p">:</span> <span class="kc">border-box</span><span class="p">;</span>
            <span class="k">box-sizing</span><span class="p">:</span> <span class="kc">border-box</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>I am using the <a href="https://github.com/postcss/autoprefixer">autoprefixer</a> of <a href="https://github.com/postcss/postcss">PostCSS</a> to help me out. However, the default configuration does  only consider the last few versions of any <a href="http://eisenbergeffect.bluespire.com/evergreen-browsers/">evergreen browser</a> – which is usually the case for other autoprefixers as well. Thus the prefixes shown above don&#39;t get added.</p>

<p>To configure the autoprefixer appropriately I started from IE9&#39;s release date in 2011. I took each browser that can be configured with <a href="https://github.com/ai/browserslist">Browserlist</a> and added the version that was also released around the same time.</p>

<p>In the end I got:</p>
<div class="highlight"><pre><span></span><span class="nx">autoprefixer</span><span class="p">({</span> <span class="nx">browsers</span><span class="o">:</span> <span class="p">[</span>
    <span class="s1">&#39;Android &gt;= 2.3&#39;</span><span class="p">,</span>
    <span class="s1">&#39;BlackBerry &gt;= 7&#39;</span><span class="p">,</span>
    <span class="s1">&#39;Chrome &gt;= 9&#39;</span><span class="p">,</span>
    <span class="s1">&#39;Firefox &gt;= 4&#39;</span><span class="p">,</span>
    <span class="s1">&#39;Explorer &gt;= 9&#39;</span><span class="p">,</span>
    <span class="s1">&#39;iOS &gt;= 5&#39;</span><span class="p">,</span>
    <span class="s1">&#39;Opera &gt;= 11&#39;</span><span class="p">,</span>
    <span class="s1">&#39;Safari &gt;= 5&#39;</span><span class="p">,</span>
    <span class="s1">&#39;OperaMobile &gt;= 11&#39;</span><span class="p">,</span>
    <span class="s1">&#39;OperaMini &gt;= 6&#39;</span><span class="p">,</span>
    <span class="s1">&#39;ChromeAndroid &gt;= 9&#39;</span><span class="p">,</span>
    <span class="s1">&#39;FirefoxAndroid &gt;= 4&#39;</span><span class="p">,</span>
    <span class="s1">&#39;ExplorerMobile &gt;= 9&#39;</span>
<span class="p">]})</span>
</pre></div>
<p>Maybe it is a bit too much to support even evergreen browsers back to 2011. Nonetheless it certainly is better than the autoprefixer&#39;s default.</p>

<p>What about you? Which configuration do you prefer in your &quot;IE9 and up&quot; projects?</p>
]]></content:encoded>
      </item>
      <item>
        <guid>http://analog-ni.co/can-t-wait-for-the-io-js-release-try-the-nightly#11291</guid>
          <pubDate>Tue, 13 Jan 2015 09:14:00 -1100</pubDate>
        <link>http://analog-ni.co/can-t-wait-for-the-io-js-release-try-the-nightly</link>
        <title>Can&#39;t wait for the io.js release? Try the nightly!</title>
        <description></description>
        <content:encoded><![CDATA[<p>The first beta of <a href="https://iojs.org">io.js</a> is about to be released in a couple of hours. If you can&#39;t wait, though, here is how you can take your existing node.js project and try it out on the io.js nightly.</p>

<p><strong>Update:</strong> The release is out. You may now also use <a href="https://iojs.org/dist/latest/">https://iojs.org/dist/latest/</a> in step 1 and then continue the same way.</p>

<ol>
<li>Download the latest io.js nightly from <a href="https://iojs.org/download/nightly/">https://iojs.org/download/nightly/</a> (Take those with &quot;linux&quot; or &quot;darwin&quot; in their name. They contain the prebuilt binaries.)</li>
<li>Extract the archive to let&#39;s say <code>~/iojs/</code></li>
<li><code>cd</code> to the folder of your existing node.js project (preferably a copy of it)</li>
<li>Check with <code>python --version</code> that it points to version 2.6 or 2.7</li>
<li>Run <code>~/iojs/bin/npm rebuild</code> to recompile packages with native code</li>
<li>Start your app with <code>~/iojs/bin/iojs &lt;your main js file&gt;</code></li>
<li>If everything works fine you have earned the <img alt="io.js supported" src="https://img.shields.io/badge/io.js-supported-green.svg?style=flat" /> badge! <code>![io.js supported](https://img.shields.io/badge/io.js-supported-green.svg?style=flat)</code></li>
</ol>

<p>Let me know in the comments if you stumble upon some issues and I will update the steps accordingly.</p>
]]></content:encoded>
      </item>
  </channel>
</rss>