<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>David Beath (Posts about Nginx)</title><link>https://davidbeath.com/</link><description></description><atom:link href="https://davidbeath.com/categories/nginx.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Mon, 21 Feb 2022 17:09:57 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Nginx and ELB Proxy Protocol Forwarding</title><link>https://davidbeath.com/posts/elb-nginx-proxy-forwarding/</link><dc:creator>David Beath</dc:creator><description>&lt;p&gt;Recently I noticed that an application I'm hosting on &lt;a href="https://aws.amazon.com/elasticbeanstalk/"&gt;AWS Elastic Beanstalk&lt;/a&gt; wasn't logging the Client IP Address of my users. After a lot of digging I found the issue was to do with the configuration of the &lt;a href="https://www.nginx.com/resources/wiki/"&gt;Nginx&lt;/a&gt; servers running on the &lt;a href="https://aws.amazon.com/ec2/"&gt;EC2&lt;/a&gt; instances and in my application's &lt;a href="https://www.docker.com/"&gt;Docker&lt;/a&gt; container, and in the TCP passthrough configuration of the &lt;a href="https://aws.amazon.com/elasticloadbalancing/"&gt;Elastic Load Balancer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So here's a quick post about my particular setup and the configuration I used to fix this issue of Client IP Addresses not being forwarded.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;

&lt;h3&gt;Elastic Beanstalk Setup&lt;/h3&gt;
&lt;p&gt;In a little more detail, my setup consists of an application hosted within a Docker container running on EC2 instances configured by Elastic Beanstalk, which sit behind an Elastic Load Balancer (ELB). Because of issues with Certificate support in ELB, I'm not using AWS's Certificate Manager or using the built-in SSL termination in ELB, but instead using TCP passthrough on the ELB, and using a custom Nginx configuration on each EC2 instance to terminate the SSL connection. The Docker container on each instance also has it's own Nginx configuration, which proxies the application server, in my case &lt;a href="https://uwsgi-docs.readthedocs.io/en/latest/"&gt;UWSGI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The steps that a request takes to get to the application are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;User makes an HTTPS request.&lt;/li&gt;
&lt;li&gt;ELB uses TCP passthrough to pass the encrypted request to an EC2 instance.&lt;/li&gt;
&lt;li&gt;Nginx in EC2 decrypts the HTTPS request and passes the HTTP to it's Docker container.&lt;/li&gt;
&lt;li&gt;The Nginx server on Docker proxies the request to UWSGI.&lt;/li&gt;
&lt;li&gt;The application hosted by UWSGI handles the request.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In all, the parts that you need to configure to forward the Client IP Address are the TCP passthrough on ELB and each of the two Nginx servers.&lt;/p&gt;
&lt;h3&gt;Proxy Protocol&lt;/h3&gt;
&lt;p&gt;The first problem is that if you're using a TCP load balancer to pass through the request, the load balancer will not add an &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For"&gt;&lt;em&gt;X-Forwarded-For&lt;/em&gt;&lt;/a&gt; header, and so the downstream Nginx server will only see the IP Address of the load balancer. The problem and part of the solution is &lt;a href="https://chrislea.com/2014/03/20/using-proxy-protocol-nginx/"&gt;described in better detail here&lt;/a&gt;. The linked solution is a little different from what I'm going to show below, because I'm proxying the request another hop down the line, but please read the link to better understand what's going on.&lt;/p&gt;
&lt;p&gt;The first step is to enable Proxy Protocol support on the Elastic Load Balancer. AWS has a &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html"&gt;good tutorial&lt;/a&gt; on how to do that.&lt;/p&gt;
&lt;p&gt;Once the ELB has Proxy Protocol support enabled, you can configure the Nginx server on the EC2 instances. The relevant parts of the configuration look something like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;log_format&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;elb_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$proxy_protocol_addr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$remote_user'&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s"&gt;'[&lt;/span&gt;&lt;span class="nv"&gt;$time_local]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$request"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="nv"&gt;$status&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$body_bytes_sent&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;'&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;                    &lt;/span&gt;&lt;span class="s"&gt;'"&lt;/span&gt;&lt;span class="nv"&gt;$http_referer"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$http_user_agent"'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="k"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;ssl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;http2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;proxy_protocol&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;localhost&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;set_real_ip_from&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="mi"&gt;172&lt;/span&gt;&lt;span class="s"&gt;.31.0.0/20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;real_ip_header&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="s"&gt;proxy_protocol&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;access_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/log/nginx/elb-access.log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;elb_log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# SSL Certificate settings go here.&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_pass&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="s"&gt;https://docker&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_http_version&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="s"&gt;.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_set_header&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;Connection&lt;/span&gt;&lt;span class="w"&gt;         &lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_set_header&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;Host&lt;/span&gt;&lt;span class="w"&gt;               &lt;/span&gt;&lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_set_header&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;X-Real-IP&lt;/span&gt;&lt;span class="w"&gt;          &lt;/span&gt;&lt;span class="nv"&gt;$proxy_protocol_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_set_header&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="nv"&gt;$proxy_protocol_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;proxy_set_header&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;X-Forwarded-Proto&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="nv"&gt;$scheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Here's what's happening in the above config:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &lt;em&gt;listen&lt;/em&gt; directive now has &lt;em&gt;proxy_protocol&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;set_real_ip_from&lt;/em&gt; tells Nginx the real CIDR range of addresses that the ELB is using.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;real_ip_header&lt;/em&gt; tells us that we're using the &lt;em&gt;proxy_protocol&lt;/em&gt; value to access the client headers.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;X-Real-IP&lt;/em&gt; and &lt;em&gt;X-Forwarded-For&lt;/em&gt; use the &lt;em&gt;$proxy_protocal_addr&lt;/em&gt;, which is the client IP information taken from the proxy protocol.&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;elb_log&lt;/em&gt; format is now using the &lt;em&gt;$proxy_protocal_addr&lt;/em&gt; for the client IP.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Also note that the &lt;em&gt;listen&lt;/em&gt; directive can support both &lt;em&gt;http2&lt;/em&gt; and &lt;em&gt;proxy_protocol&lt;/em&gt;, so if your version of Nginx supports &lt;a href="https://hpbn.co/http2/"&gt;HTTP/2&lt;/a&gt; then you can enable that just fine. However, the &lt;em&gt;proxy_http_version&lt;/em&gt; directive in this case is still &lt;em&gt;1.1&lt;/em&gt;, as it &lt;a href="https://mailman.nginx.org/pipermail/nginx/2015-December/049445.html"&gt;doesn't make sense&lt;/a&gt; to use HTTP/2 for proxy backends.&lt;/p&gt;
&lt;p&gt;If you deployed the above config, you should now see that Nginx server on the EC2 instance is now logging the correct client IP Address.&lt;/p&gt;
&lt;h3&gt;Multiple Nginx Proxies&lt;/h3&gt;
&lt;p&gt;Now that we have the Nginx server on the EC2 instance receiving the correct Client IP from the Load Balancer, we need to foward that IP on to the Nginx server in the Docker container.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;X-Forwarded-For&lt;/em&gt; and &lt;em&gt;X-Real-IP&lt;/em&gt; directives in the above config will properly forward the Client IP from the EC2 instance's Nginx server. However, Nginx appends each proxy's IP address to the &lt;em&gt;X-Forwarded-For&lt;/em&gt; header, as described in more detail &lt;a href="https://distinctplace.com/2014/04/23/story-behind-x-forwarded-for-and-x-real-ip-headers/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The solution to this is in the last Nginx proxy configuration is to include the IP address ranges of all previous known proxies in the &lt;em&gt;set_real_ip_from&lt;/em&gt; directive. You can then set the &lt;em&gt;real_ip_header&lt;/em&gt; directive to &lt;em&gt;X-Forwarded-For&lt;/em&gt;. The final piece is to set &lt;em&gt;real_ip_recursive&lt;/em&gt; to &lt;em&gt;on&lt;/em&gt;, which will return the leftmost (original) IP instead of the rightmost (most recent) IP from the &lt;em&gt;X-Forwarded-For&lt;/em&gt; header.&lt;/p&gt;
&lt;p&gt;My Nginx configuration for the Docker container now looks like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;upstream&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;app&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;unix:///tmp/uwsgi.sock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="k"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;default_server&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;set_real_ip_from&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;172&lt;/span&gt;&lt;span class="s"&gt;.31.0.0/20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# IP of the ELB&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;set_real_ip_from&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="mi"&gt;172&lt;/span&gt;&lt;span class="s"&gt;.17.0.0/20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="c1"&gt;# IP of the EC2 instance&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;real_ip_header&lt;/span&gt;&lt;span class="w"&gt;      &lt;/span&gt;&lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;real_ip_recursive&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;uwsgi_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="kn"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;uwsgi_params&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;You can see that I've included the IP ranges of both the ELB and the EC2 instance. With a config similar to this you should now see the Nginx instance in the Docker container log the correct Client IP, and pass that IP through to your application.&lt;/p&gt;</description><category>hosting</category><category>IT</category><category>Nginx</category><category>tutorial</category><category>Web</category><guid>https://davidbeath.com/posts/elb-nginx-proxy-forwarding/</guid><pubDate>Mon, 17 Apr 2017 10:35:06 GMT</pubDate></item><item><title>Configuring SSL in Nginx</title><link>https://davidbeath.com/posts/configuring-ssl-in-nginx/</link><dc:creator>David Beath</dc:creator><description>&lt;p&gt;This post aims to be a fairly thorough guide to getting &lt;a href="https://en.wikipedia.org/wiki/Secure_Sockets_Layer"&gt;SSL&lt;/a&gt; up and running on an &lt;a href="https://en.wikipedia.org/wiki/Nginx"&gt;Nginx&lt;/a&gt; server, largely for my own reference in future, but it may prove useful to anyone else who stumbles across it. I'm going to assume that you have a working installation of Nginx, or know how to get one going. If not, then bookmark this page and find a tutorial on how to get it going first, such as the section on Nginx in my post &lt;a href="https://davidbeath.com/posts/installing-tiny-tiny-rss-from-scratch.html"&gt;here&lt;/a&gt;, or the &lt;a href="https://nginx.org/en/docs/install.html"&gt;Installation&lt;/a&gt; and &lt;a href="https://nginx.org/en/docs/beginners_guide.html"&gt;Beginner's Guide&lt;/a&gt; pages on the official site.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;

&lt;h3&gt;Get an SSL Certificate&lt;/h3&gt;
&lt;p&gt;The first step in setting up SSL on your server is to procure an &lt;a href="https://www.globalsign.eu/ssl-information-center/what-is-an-ssl-certificate.html"&gt;SSL Certificate&lt;/a&gt; from an approved &lt;a href="https://en.wikipedia.org/wiki/Certificate_authority"&gt;Certificate Authority&lt;/a&gt; (CA). The easiest way to do this is to purchase one from a certificate reseller such as &lt;a href="https://www.cheapssls.com/"&gt;CheapSSLs.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For a single site with no subdomains, such as a blog, that doesn't require all the extra features of more expensive certificates, then a certificate such as &lt;a href="https://www.cheapssls.com/comodo-ssl-certificates/positivessl.html"&gt;Comodo Positive SSL&lt;/a&gt; will do fine.&lt;/p&gt;
&lt;p&gt;Once you've purchased the certificate, you'll need to create a Certificate Signing Request.&lt;/p&gt;
&lt;h4&gt;Creating a CSR&lt;/h4&gt;
&lt;p&gt;A Certificate Signing Request (CSR) is a file that contains the application information for your certificate, such as your location and the name of the domain you want to secure, as well as your &lt;a href="https://en.wikipedia.org/wiki/Public-key_cryptography"&gt;Public Key&lt;/a&gt;. For creating the CSR we'll be using &lt;a href="https://www.openssl.org/"&gt;OpenSSL&lt;/a&gt;, so if you don't have that on your server you can install it with the following command:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo apt-get install openssl
&lt;/pre&gt;
&lt;p&gt;Before we start creating files, it's recommended that you have a proper location to store them in. On Linux systems this would be something like &lt;code&gt;/etc/ssl/localcerts/&lt;/code&gt;, so lets start there.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo mkdir /etc/ssl/localcerts
&amp;gt; sudo &lt;span class="nb"&gt;cd&lt;/span&gt; /etc/ssl/localcerts
&lt;/pre&gt;
&lt;p&gt;To generate the public and private keys that will be used for the CSR, use this command:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo openssl req -nodes -newkey rsa:2048 -days &lt;span class="m"&gt;365&lt;/span&gt; -keyout myserver.key -out server.csr
&lt;/pre&gt;
&lt;p&gt;This will create two files; &lt;code&gt;myserver.key&lt;/code&gt;, the private key file, and &lt;code&gt;server.csr&lt;/code&gt;, the Certificate Signing Request. When you enter the above command, you should of course set the name of both files to one appropriate for the server you are securing.&lt;/p&gt;
&lt;p&gt;Generally your CA should require you to use &lt;a href="https://en.wikipedia.org/wiki/RSA_(algorithm)"&gt;RSA&lt;/a&gt; 2048, this is specified with the &lt;code&gt;-newkey rsa:2048&lt;/code&gt; portion of the command. If you purchased a certificate that is valid for more than a year, then the &lt;code&gt;-days 365&lt;/code&gt; portion should be set to the number of days your certificate is valid.&lt;/p&gt;
&lt;p&gt;Once you've entered the above command, you'll be asked to enter the details into your CSR. These details (with examples) are:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;Country Name &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; letter code&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;AU&lt;span class="o"&gt;]&lt;/span&gt;: US
State or Province Name &lt;span class="o"&gt;(&lt;/span&gt;full name&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;Some-State&lt;span class="o"&gt;]&lt;/span&gt;: California
Locality Name &lt;span class="o"&gt;(&lt;/span&gt;eg, city&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;: Los Angeles
Organization Name &lt;span class="o"&gt;(&lt;/span&gt;eg, company&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;Internet Widgits Pty Ltd&lt;span class="o"&gt;]&lt;/span&gt;: ACME Ltd
Organizational Unit Name &lt;span class="o"&gt;(&lt;/span&gt;eg, section&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;: Widgets
Common Name &lt;span class="o"&gt;(&lt;/span&gt;eg, YOUR name&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;: widgets.acme.com
Email Address &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;/pre&gt;
&lt;p&gt;And two 'extra', comletely optional details:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;A challenge password &lt;span class="o"&gt;[]&lt;/span&gt;:
An optional company name &lt;span class="o"&gt;[]&lt;/span&gt;:
&lt;/pre&gt;
&lt;p&gt;If you enter a period '.' into one of the above fields then the field will be left blank.&lt;/p&gt;
&lt;p&gt;One thing that seems to get glossed over is that the &lt;strong&gt;Common Name&lt;/strong&gt; field is the &lt;a href="https://en.wikipedia.org/wiki/Fully_qualified_domain_name"&gt;fully qualified domain name&lt;/a&gt; (FQDN) of your site. So if you're wanting to secure &lt;code&gt;example.com&lt;/code&gt;, then that's what you put in the common name field. If you're securing a subdomain like &lt;code&gt;subdomain.example.com&lt;/code&gt;, then make sure you enter it like that. Unless you've bought a wildcard certificate, then your certificate will only cover a single domain or subdomain.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WARNING&lt;/strong&gt;: Make very sure you've entered the Common Name correctly before you submit your CSR. (Yes, I have made this mistake. Don't do important things when you're tired.)&lt;/p&gt;
&lt;p&gt;Once you've created the CSR, go to the site you purchased your certificate from and activate it. You'll be asked to enter your CSR into an online form, so open your CSR file up in a text editor and paste the entire contents into the enrollment form, including the BEGIN and END lines.&lt;/p&gt;
&lt;h4&gt;Installing your Certificate&lt;/h4&gt;
&lt;p&gt;Once your CSR has been approved, you'll get an email containing your new certificate, and the Root certificates required. Copy these to the folder where you intend to store your certificates. For this example we'll use the SSL localcerts directory we created previously &lt;code&gt;/etc/ssl/localcerts/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You may want to combine the certificates together into one file. If so, then you can use the &lt;code&gt;cat&lt;/code&gt; command to concatenate the files in reverse order of authority. For example, if you've got a Comodo Positive SSL Certificate, then you should have three files; the certificate for your domain (eg. &lt;code&gt;example.com.crt&lt;/code&gt;), the intermediate certificate (eg. &lt;code&gt;PositiveSSLCA2.crt&lt;/code&gt;), and the root certificate (eg. &lt;code&gt;AddTrustExternalCARoot.crt&lt;/code&gt;). So to concatenate these files the command would be:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo cat example.com.crt PositiveSSLCA2.crt AddTrustExternalCARoot.crt &amp;gt;&amp;gt; example.com.chained.crt
&lt;/pre&gt;
&lt;h3&gt;Configuring Nginx&lt;/h3&gt;
&lt;p&gt;You can now set about adding your certificate to your server configuration in Nginx. If you installed Nginx from a package, it should have SSL enabled already, otherwise if you're building from source you'll have to specifically enable it during configuration.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; ./configure --with-http_ssl_module --with_http_spdy_module
&lt;/pre&gt;
&lt;p&gt;If you're using SSL then you may as well use &lt;a href="https://en.wikipedia.org/wiki/SPDY"&gt;SPDY&lt;/a&gt; to help speed up the connection.&lt;/p&gt;
&lt;p&gt;Now you can configure your Virtual Hosts for SSL. In the server block of your configuration, you need to set it to listen on port 443, specify the certificate and private key, and SSL protocols and cipher settings.&lt;/p&gt;
&lt;p&gt;This is an example of a basic Nginx Virtual Host file with SSL enabled:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;443&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;ssl&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;spdy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;root&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/srv/www/example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;index&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;index.html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;ssl_certificate&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/etc/ssl/localcerts/example.com.chained.crt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;ssl_certificate_key&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/etc/ssl/localcerts/example.com.key&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The listen directive specifies that the server should listen on the HTTPS port, 443, instead of the usual port 80, that SSL is on, and that it is using the SPDY protocol. The ssl_certificate directive points to the location of the chained certificate we created. The ssl_certificate_key directive points to the private key that was created when we created the certificate signing request.&lt;/p&gt;
&lt;p&gt;The above provides the minimum configuration required to enable SSL on Nginx. All you need to do is restart Nginx, and you should be able to visit your site using HTTPS.&lt;/p&gt;
&lt;h4&gt;SSL Security in Nginx&lt;/h4&gt;
&lt;p&gt;Of course, the above basic configuration only uses the most basic default security, so you'll probably want to do some additional configuration.&lt;/p&gt;
&lt;p&gt;The first thing you'll want to do is to set the SSL Ciphers your server will use. This &lt;a href="https://blog.cloudflare.com/staying-on-top-of-tls-attacks"&gt;post&lt;/a&gt; has a good explanation on the background of using ciphers. The exact list of ciphers you should use is dependent on how secure you want to be, and what performance considerations you have. The ciphers I use are:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;ssl_ciphers&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This gives me an 'A' rating on the &lt;a href="https://www.ssllabs.com/ssltest/index.html"&gt;SSL Server Test&lt;/a&gt;, while still providing decent performance.&lt;/p&gt;
&lt;p&gt;The rest of my SSL configuration is as follows:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;ssl_session_timeout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;ssl_prefer_server_ciphers&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;ssl_session_cache&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;shared:SSL:10m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;ssl_protocols&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;TLSv1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;TLSv1.1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;TLSv1.2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;ssl_ecdh_curve&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;secp521r1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;ssl_session_timeout 5m;&lt;/em&gt; is the time it takes for the client's ssl session information to be removed from the cache. A longer time means that the ssl session won't have to be renegotiated as often, improving performance if there are a lot of connections. 5 minutes is the default time for many client browsers.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ssl_prefer_server_ciphers on;&lt;/em&gt; means that the server will prefer to use ciphers specified in the &lt;code&gt;ssl_ciphers&lt;/code&gt; directive over the ciphers preferred by clients.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ssl_session_cache shared:SSL:10m;&lt;/em&gt; lets Nginx use its own cache instead of the one provided by OpenSSL, thus allowing Nginx to separate SSL jobs between its own workers.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;/em&gt; is the list of supported protocols, which in this case is only TLSv1 or greater. SSLv3 and below are not recommended due to security vulnerabilities, and most browsers support TLS now.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;ssl_ecdh_curve secp521r1;&lt;/em&gt; is the &lt;a href="https://en.wikipedia.org/wiki/Elliptic_curve_cryptography"&gt;Elliptic curve&lt;/a&gt; key used for the ECDHE cipher.&lt;/p&gt;
&lt;p&gt;If you want a much more in-depth look at securely configuring Nginx, then &lt;a href="https://calomel.org/nginx.html"&gt;calomel.org&lt;/a&gt; has an excellently thorough post detailing nearly everything you need to know.&lt;/p&gt;
&lt;h4&gt;Redirecting to HTTPS&lt;/h4&gt;
&lt;p&gt;If you want to redirect all your traffic to the SSL version of your site, then you'll need to specify another Virtual Host to accept HTTP traffic and redirect it to HTTPS.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="k"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;example.com&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;301&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;https://example.com&lt;/span&gt;&lt;span class="nv"&gt;$request_uri&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;This server block listens on port 80, and then performs an &lt;a href="https://en.wikipedia.org/wiki/HTTP_301"&gt;HTTP 301&lt;/a&gt; redirect to the requested URI. As this is a permanent redirect of a full URL then &lt;code&gt;return&lt;/code&gt; rather than &lt;code&gt;rewrite&lt;/code&gt; is the correct Nginx directive to use.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;You should now have a secure implementation of SSL on your website. You may want to use tools such as &lt;a href="https://developers.google.com/speed/pagespeed/"&gt;pagespeed&lt;/a&gt; to test the speed of your site, as it may require a bit of tweaking to get the best balance between performance and security.&lt;/p&gt;</description><category>IT</category><category>Nginx</category><category>servers</category><category>tutorial</category><category>Web</category><guid>https://davidbeath.com/posts/configuring-ssl-in-nginx/</guid><pubDate>Sun, 17 Nov 2013 03:32:49 GMT</pubDate></item><item><title>Installing Tiny Tiny RSS from scratch</title><link>https://davidbeath.com/posts/installing-tiny-tiny-rss-from-scratch/</link><dc:creator>David Beath</dc:creator><description>&lt;p&gt;Considering that a couple of times now I've been a proponent of using an RSS reader, I figured it was time I wrote a tutorial on how to install &lt;a href="https://tt-rss.org/"&gt;Tiny Tiny RSS&lt;/a&gt;, using &lt;a href="https://nginx.org/"&gt;Nginx&lt;/a&gt; as the server and &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; for the database. While as with any piece of software there are a number of tutorials and guides already out there, I've found that none of them provided a complete instruction set that didn't have me running into and searching for solutions to multiple errors. To that end, this tutorial aims to both provide as complete a set of fool-proof instructions as I can make, both for newbies to self-hosting, and simply as a reference for my future self should I need to do this again.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;

&lt;p&gt;This set of instructions assumes that you're running a Debian based Linux distro. I've tested this setup on a clean Ubuntu Server 12.04 virtual machine, and the settings are roughly the same as I'm using on my Debian server. It's assumed that you either know how to set up a server already, or are capable of reading a tutorial to do so (If not, then why are you reading this? Go use &lt;a href="https://cloud.feedly.com/"&gt;Feedly&lt;/a&gt;). There are some very good tutorials at &lt;a href="https://www.digitalocean.com/community/"&gt;Digital Ocean&lt;/a&gt; and &lt;a href="https://library.linode.com/"&gt;Linode&lt;/a&gt;, and I'd recommend either of them for hosting purposes.&lt;/p&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;p&gt;On to the install. While not strictly necessary, the first thing I recommend is to make sure that your server is using the correct time, so install ntp to keep the system clock updated.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo apt-get install ntp
&lt;/pre&gt;
&lt;p&gt;For most of the commands in this tutorial you'll need super user privileges, so you can either run them as root (not recommended) or use &lt;code&gt;sudo&lt;/code&gt; like I've used in this tutorial.
You'll also need to edit a bunch of files in a text editor. I've used &lt;code&gt;nano&lt;/code&gt; for this tutorial because it's easier to use and you can just copy the commands straight, but I usually use &lt;code&gt;vim&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;PHP&lt;/h3&gt;
&lt;p&gt;Unfortunately, despite the fact that &lt;a href="https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/"&gt;PHP sucks&lt;/a&gt; (seriously, read the article, even if you disagree it's an interesting read), Tiny Tiny RSS is built with PHP. However, just because a language sucks doesn't mean that programs written in it necessarily have to, and tt-rss is the best of the self-hosted RSS readers. Still, that means you're going to have to install PHP, and get it working nicely with Nginx.&lt;/p&gt;
&lt;p&gt;Install PHP 5 and the components necessary to get it playing nicely with everything else.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo apt-get install php5 php5-fpm php5-curl php5-pgsql php5-gd php5-mcrypt php5-cli
&lt;/pre&gt;
&lt;p&gt;There's one line in php.ini you'll need to change, which will prevent a possible &lt;a href="https://wiki.nginx.org/Pitfalls#Passing_Every_.7E_.5C.php.24_request_to_to_PHP"&gt;security issue&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano /etc/php5/fpm/php.ini
&lt;/pre&gt;
&lt;p&gt;Change this line:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="na"&gt;cgi.fix_pathinfo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;1&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;To this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="na"&gt;cgi.fix_pathinfo&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;0&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;The other change is to make PHP-FPM listen on a UNIX socket rather than a TCP socket.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano /etc/php5/fpm/pool.d/www.conf
&lt;/pre&gt;
&lt;p&gt;Change the line:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="na"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;127.0.0.1:9000&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;To:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="na"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/run/php5-fpm.sock&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Finally, restart PHP.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo /etc/init.d/php5-fpm restart
&lt;/pre&gt;
&lt;h3&gt;Nginx&lt;/h3&gt;
&lt;p&gt;Now that PHP is configured, you'll want to configure Nginx. There's a very good &lt;a href="https://blog.martinfjordvald.com/nginx-primer/"&gt;primer&lt;/a&gt; by Martin Fjordvald on the basics of Nginx configuration which you can read to get an understanding of what's going on. If you want to dig deeper for various other settings, the &lt;a href="https://nginx.org/en/docs/"&gt;documentation&lt;/a&gt; for Nginx is quite thorough.&lt;/p&gt;
&lt;p&gt;This tutorial is going to have you build Nginx from source, since the .deb packages are not always up to date. It's really not that much harder than setting it up from a package install anyway.&lt;/p&gt;
&lt;p&gt;First, install the packages required to compile the source.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo apt-get install gcc make libpcre3-dev openssl libssl-dev
&lt;/pre&gt;
&lt;p&gt;I also prefer to have Nginx use a dedicated system account with no login or password access for a bit of extra security.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo adduser --system --no-create-home --disabled-login --disabled-password --group nginx
&lt;/pre&gt;
&lt;p&gt;Then download and unpack the latest Nginx version.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; wget https://nginx.org/download/nginx-1.5.6.tar.gz

&amp;gt; tar -xzvf nginx-1.5.6.tar.gz

&amp;gt; &lt;span class="nb"&gt;cd&lt;/span&gt; nginx-1.5.6
&lt;/pre&gt;
&lt;p&gt;The configure command sets the parameters for the build. This is where you can change the default install directory and the different modules that Nginx uses. Nginx doesn't allow you to change modules without rebuilding, so you'll need to select or deselect any modules here. The only module I'll add is the http_ssl module, which will allow you to add SSL to your site later if you wish. I also prefer to just use the default install directory, so I won't change that, but I'll set the user and group Nginx uses to the one I created earlier.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; ./configure --user&lt;span class="o"&gt;=&lt;/span&gt;nginx --group&lt;span class="o"&gt;=&lt;/span&gt;nginx --with-http_ssl_module
&lt;/pre&gt;
&lt;p&gt;Now we can build and install Nginx.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; make &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo make install
&lt;/pre&gt;
&lt;h4&gt;Nginx Configuration&lt;/h4&gt;
&lt;p&gt;Change to the directory you installed Nginx to:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /usr/local/nginx
&lt;/pre&gt;
&lt;p&gt;There are various methods people use for controlling the sites on their server. The .deb install uses a &lt;code&gt;sites-enabled&lt;/code&gt; and &lt;code&gt;sites-disabled&lt;/code&gt; style configuration, but since I don't have many sites on my server, I prefer to keep each site configuration file in the conf/ folder, and include each one manually in nginx.conf.&lt;/p&gt;
&lt;p&gt;So, for this tutorial, we'll create a ttrss.conf file.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano conf/ttrss.conf
&lt;/pre&gt;
&lt;p&gt;My ttrss.conf looks something like this (except I have SSL enabled):&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# Tiny Tiny RSS Configuration&lt;/span&gt;

&lt;span class="k"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;listen&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;domainname&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;www.domainname&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;root&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/www/ttrss&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;index&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;error_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/log/nginx/ttrss.error.log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;access_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/log/nginx/ttrss.access.log&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;try_files&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$uri&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$uri/&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;location&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;~&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="sr"&gt;\.php$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;fastcgi.conf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;# don't use fastcgi_params&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;fastcgi_pass&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;unix:/var/run/php5-fpm.sock&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;fastcgi_index&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;index.php&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;A brief primer:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;listen&lt;/em&gt;: the port that the server listens for incoming connections on.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;server_name&lt;/em&gt;: the FQDN (fully qualified domain name) that the server uses for this connection. I set this to listen on both example.com and www.example.com.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;root&lt;/em&gt;: the root directory that the site's files are located at.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;index&lt;/em&gt;: the index file that the server directs traffic to. In this case you only need index.php, but can also include index.html or .htm, or any other file you want to use as a homepage.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;error_log&lt;/em&gt;: the location of the error log for this site.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;access_log&lt;/em&gt;: the location of the access log for this site.
The first location block accepts all incoming requests:&lt;/li&gt;
&lt;li&gt;&lt;em&gt;try_files&lt;/em&gt;: this just makes the URL search engine friendly. Not really necessary in this case, but it doesn't hurt.
The second location block catches all incoming php requests:&lt;/li&gt;
&lt;li&gt;&lt;em&gt;include fastcgi.conf&lt;/em&gt;: this file comes with Nginx and includes all the parameters for using fastcgi. It's almost the same as fastcgi_params, but you'll have issues using fastcgi_params in Ubuntu 12.04, unless you include the line &lt;code&gt;SCRIPT_FILENAME $document_root$fastcgi_script_name&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;fastcgi_pass&lt;/em&gt;: the socket that fastcgi passes requests through.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;fastcgi_index&lt;/em&gt;: the index file that fastcgi uses.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Next, you'll need to edit nginx.conf.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano conf/nginx.conf
&lt;/pre&gt;
&lt;p&gt;The only change that you really need to make to this file is to add the line &lt;code&gt;include ttrss.conf&lt;/code&gt; in the http block, but this is my recommended configuration below.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# Nginx Configuration&lt;/span&gt;

&lt;span class="k"&gt;user&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;nginx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;nginx&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="k"&gt;worker_processes&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;# optimal value is number of cpu cores&lt;/span&gt;

&lt;span class="k"&gt;error_log&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;/var/log/nginx/error.log&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="s"&gt;events&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;worker_connections&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2048&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="k"&gt;http&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Virtual Host Configuration&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;ttrss.conf&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Basic Settings&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;include&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;mime.types&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;default_type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;application/octet-stream&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;sendfile&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;tcp_nopush&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;tcp_nodelay&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;client_header_timeout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;20s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;client_body_timeout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;20s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;send_timeout&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;20s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Disable Nginx version number in error pages and Server header&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;server_tokens&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Silently block all undefined vhost access&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;server_name&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;_&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="kn"&gt;return&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="c1"&gt;# Gzip Settings&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_disable&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;"msie6"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_comp_level&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_min_length&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;

&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_vary&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_proxied&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;any&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="kn"&gt;gzip_types&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Finally, start Nginx.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo /usr/local/nginx/sbin/nginx
&lt;/pre&gt;
&lt;p&gt;If you need to make any changes to Nginx after it's been started, just open and change the config files. Then run this command to reload the Nginx with the new configuration.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo /usr/local/nginx/sbin/nginx -s reload
&lt;/pre&gt;
&lt;h3&gt;Postgres&lt;/h3&gt;
&lt;p&gt;Tiny Tiny RSS recommends using &lt;a href="https://www.postgresql.org/"&gt;PostgreSQL&lt;/a&gt; over MySQL for the database, as PostgreSQL is slightly faster. For a single user, it probably wouldn't make much difference, depending on how many feeds you have. The instructions for installing PostgreSQL are mostly taken from the Ubuntu community wiki &lt;a href="https://help.ubuntu.com/community/PostgreSQL"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Install PostgreSQL.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo apt-get install postgresql
&lt;/pre&gt;
&lt;p&gt;Log in to the postgres command line as user postgres.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo -u postgres psql postgres
&lt;/pre&gt;
&lt;p&gt;Change the password for the postgres user. Type in the command below, hit enter, then enter as password. Make sure to save all your passwords in a good password manager somewhere. I recommend &lt;a href="https://keepass.info/"&gt;KeePass&lt;/a&gt;.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; &lt;span class="se"&gt;\p&lt;/span&gt;assword postgres
&lt;/pre&gt;
&lt;p&gt;While you're still in the postgres command line, create a database and database user for tt-rss. The password must be entered surrounded by single quotes.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c1"&gt;# CREATE USER ttrss WITH PASSWORD 'password';&lt;/span&gt;

&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c1"&gt;# CREATE DATABASE ttrssdb;&lt;/span&gt;

&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c1"&gt;# GRANT ALL PRIVILEGES ON DATABASE ttrssdb to ttrss;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Exit the postgres command line.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="nv"&gt;postgres&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="c1"&gt;# \q&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;From this point, you might be able to get tt-rss to access the database, but I wasn't until I edited a line in the postgresql config to allow access.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano /etc/postgresql/9.1/main/pg_hba.conf
&lt;/pre&gt;
&lt;p&gt;Add this line to allow tt-rss to use the database:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span class="na"&gt;local all ttrss md5&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;Now restart PostgreSQL.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo service postgresql restart
&lt;/pre&gt;
&lt;h3&gt;Tiny Tiny RSS&lt;/h3&gt;
&lt;p&gt;Finally, it's now time to install Tiny Tiny RSS itself. Yeah, I know it takes a while to get here. I assure you, it's worth it in the end, and you shouldn't have to worry about it much at all once you've got it properly set up. The installation instructions for tt-rss can be be found &lt;a href="https://tt-rss.org/redmine/projects/tt-rss/wiki/InstallationNotes"&gt;here&lt;/a&gt;, but once again they seem somewhat incomplete.&lt;/p&gt;
&lt;p&gt;First, make a directory for tt-rss to be served from. This should be the same as the directory you specified as root in your ttrss.conf file for Nginx.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo mkdir -p /var/www/ttrss
&lt;/pre&gt;
&lt;p&gt;You'll need to set the owner of the directory to the user that you're installing and running tt-rss as.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo chown -R user:group /var/www/
&lt;/pre&gt;
&lt;p&gt;Now change to the directory above.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /var/www
&lt;/pre&gt;
&lt;p&gt;Download and extract the latest version of Tiny Tiny RSS.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; wget https://github.com/gothfox/Tiny-Tiny-RSS/archive/1.10.tar.gz

&amp;gt; tar -xzvf &lt;span class="m"&gt;1&lt;/span&gt;.10.tar.gz
&lt;/pre&gt;
&lt;p&gt;Rename the extracted directory so that it matches the root directory you specified earlier, then open the directory.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; mv Tiny-Tiny-RSS-1.10/ ttrss

&amp;gt; &lt;span class="nb"&gt;cd&lt;/span&gt; /var/www/ttrss
&lt;/pre&gt;
&lt;p&gt;The following folders need to have their permissions changed to be writable by anyone with an account on the system, or tt-rss won't be able to save files there.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo chmod -R &lt;span class="m"&gt;777&lt;/span&gt; cache/images/ cache/js/ cache/export/ cache/upload/ feed-icons/ lock/
&lt;/pre&gt;
&lt;p&gt;Now you should be able to navigate in your browser to the site that you are hosting tt-rss from. This should be the same as the server_name you specified in ttrss.conf. If you installed tt-rss into a sub-folder of the domain, then the address will be &lt;code&gt;https://domainname/ttrss/&lt;/code&gt;. If you got the configuration correct, you should see the Tiny Tiny RSS install page.&lt;/p&gt;
&lt;p&gt;The installation page will have a few fields to enter. These will be the credentials for tt-rss to use the database, as well as the full URL that you'll access tt-rss from. Once you've entered the database details, click the 'Test Configuration' button. If there are errors, you'll get a message saying so, and it shouldn't be too hard to figure out what to do from there. If it's good to go, you'll see a text box with a lot of configuration lines. Copy that config data to your clipboard, and then into a config file on your server with:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; sudo nano /var/www/ttrss/config.php
&lt;/pre&gt;
&lt;p&gt;Save that file, and reload tt-rss in your browser. You should now be able to login with the default user &lt;code&gt;admin&lt;/code&gt; and password &lt;code&gt;password&lt;/code&gt;. Once you're logged in, change the admin settings in the preferences at top right.&lt;/p&gt;
&lt;p&gt;The final required step is to set up automatic updating of your feeds. You can skip this, but you'll have to manually click on each feed to check for updates if you don't. The &lt;a href="https://www.gnu.org/software/screen/"&gt;screen&lt;/a&gt; command will permanently run feed updates in the background, defaulting to once every 30 minutes.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&amp;gt; screen -d -m php ./update_daemon2.php
&lt;/pre&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;You should now have a working installation of Tiny Tiny RSS on your server, accessible from anywhere in the world. If you've used RSS Readers before, you can import your feeds from an OPML file, otherwise, find some good blogs and start adding feeds.&lt;/p&gt;</description><category>hosting</category><category>IT</category><category>Nginx</category><category>RSS</category><category>servers</category><category>tutorial</category><category>Web</category><guid>https://davidbeath.com/posts/installing-tiny-tiny-rss-from-scratch/</guid><pubDate>Wed, 02 Oct 2013 03:43:39 GMT</pubDate></item></channel></rss>