<?xml version="1.0" encoding="UTF-8"?><rss 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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gregory Durelle on Medium]]></title>
        <description><![CDATA[Stories by Gregory Durelle on Medium]]></description>
        <link>https://medium.com/@gdurelle?source=rss-a051fde7b12d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*cDtxDeKp11Z2asIS.jpeg</url>
            <title>Stories by Gregory Durelle on Medium</title>
            <link>https://medium.com/@gdurelle?source=rss-a051fde7b12d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:18:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gdurelle/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Monit(or) your Apps]]></title>
            <link>https://medium.com/@gdurelle/monit-or-your-apps-e9ec3429a86?source=rss-a051fde7b12d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9ec3429a86</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Gregory Durelle]]></dc:creator>
            <pubDate>Thu, 24 Mar 2016 13:06:34 GMT</pubDate>
            <atom:updated>2016-03-24T13:06:34.394Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*tQvoTKNJVrnS3Gy09g4kmA.png" /></figure><p>To monitor critical processes, get alerts (emails/chat notifications), to restart automatically a process that crashed for any reason, we all need a tool.</p><p>Some of us use SaaS like <a href="https://newrelic.com/">New Relic</a>, <a href="https://www.nagios.com/">Nagios</a>, or <a href="https://scoutapp.com/">Scoutapp</a>.<br>Some of us prefer solutions like <a href="http://godrb.com/">God</a> or <a href="https://github.com/bluepill-rb/bluepill">Bluepill</a>.</p><p>There is another one.</p><p>Today i’m gonna talk about another one: <a href="https://mmonit.com/monit"><strong>Monit</strong></a>. <br>It’s opensource (AGPL), simple, stable and fast.</p><p>You need <em>root</em> rights to install it:</p><pre>apt-get install monit</pre><p>You can find it then in <em>/etc/monit/</em>. Here are 3 things:</p><ul><li>a <em>monitrc</em> file: The config of monit is here.</li><li>a <em>conf.d</em> directory: At the end of monitrc, this directory is included, so all specific config will be added here.</li><li>a <em>monitrc.d</em> directory: ready-made config files for main process you often wanna monitor.</li></ul><h4>monitrc</h4><p>The config file will let you specify how often you wanna check processes, where the log files are handled, some basic checks on the system, files and programs are also added in comments.</p><p>Around the lines <em>118–123</em> we can add a web interface to see our checked processes being green or not, plus others things:</p><pre>set httpd port 2812 and<br>  use address localhost <br>  allow localhost # allow localhost to connect to the server and<br>  allow admin:monit # require user ‘admin’ with password ‘monit’</pre><p>The <strong>first</strong> line set the webserver on the port 2812 (default port for monit)<br>The <strong>second</strong> line says we only accepts connection from localhost, which is ok here because we’ll use Nginx as proxy.<br>The <strong>third</strong> and <strong>forth</strong> line are already explained.</p><p>Save the file and type :</p><pre>sudo monit -t</pre><p>If everything is configured properly it should answer:</p><blockquote>Control file syntax OK</blockquote><p>Then just reload monit:</p><pre>sudo monit reload</pre><h4>Nginx</h4><p>In your main server bloc config add the following location :</p><pre>location /monit/ {<br>  rewrite ^/monit/(.*) /$1 break;<br>  proxy_ignore_client_abort on;<br>  proxy_pass <a href="http://localhost:2812;">http://localhost:2812;</a> <br>  proxy_redirect <a href="http://localhost:2812/">http://localhost:2812</a> /monit; <br>}</pre><p>No magic here, it is a copy/paste from <a href="https://mmonit.com/wiki/Monit/Nginx">the documentation</a>.</p><p>Now go to <em>yourdomain.example.com</em>, you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2X4VJ3CrWTlqxRaOfNowg.png" /><figcaption>Monit Web UI.</figcaption></figure><h4>Add checks in conf.d</h4><p>Thanks to existing examples in <em>/etc/monit/monitrc.d</em> you can just <em>cp</em> this files in <em>config.d/</em> for them to be included in checks, they will also appear in the Web UI. Try:</p><pre>sudo cp /etc/monit/monitrc.d/nginx /etc/monit/conf.d/nginx<br>sudo monit reload</pre><p>And reload your WebApp. Nginx processes and files should now appear.</p><p>Here is an example of non-existing check I added: <br><em>/etc/monit/config.d/redis</em></p><pre>check process redis-server<br>  with pidfile “/var/run/redis/redis-server.pid”<br>  start program = “/etc/init.d/redis-server start”<br>  stop program = “/etc/init.d/redis-server stop”<br>  if 2 restarts within 3 cycles then timeout<br>  if totalmem &gt; 500 Mb then alert<br>  if children &gt; 255 for 5 cycles then stop<br>  if cpu usage &gt; 95% for 3 cycles then restart<br>  if failed host 127.0.0.1 port 6379 then restart<br>  if 5 restarts within 5 cycles then timeout</pre><p>The same goes for sidekiq, unicorn, postgresql, …</p><h4>Restart your app on deploy</h4><p>You might need to add some task in your deploy script to restart some processes (like unicorn and sidekiq). <br>In Capistrano I added this:</p><pre>namespace :deploy do</pre><pre>  task :restart do<br>    on roles(:app), in: :sequence do<br>     sudo “monit restart unicorn”<br>     sudo “monit restart sidekiq”<br>    end<br>  end</pre><pre>end<br>after &#39;deploy:publishing&#39;, &#39;deploy:restart&#39;</pre><p>There is difference between Monit and M/Monit.</p><blockquote>M/Monit expand on Monit’s capabilities and provides monitoring and management of all your Monit enabled hosts.</blockquote><p>M/Monit is licenced and on pay-once model. It is really cheap for the service it gives.</p><p>Have fun !</p><p><strong>If I forgot anything, or got wrong or more complicated than needed, please tell me ! I’m always eager to learn a better way :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9ec3429a86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gitlab behind a reverse proxy (Nginx)]]></title>
            <link>https://medium.com/@gdurelle/gitlab-behind-a-reverse-proxy-nginx-5245476747fe?source=rss-a051fde7b12d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5245476747fe</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[proxy]]></category>
            <dc:creator><![CDATA[Gregory Durelle]]></dc:creator>
            <pubDate>Tue, 15 Mar 2016 15:01:09 GMT</pubDate>
            <atom:updated>2016-03-15T15:01:09.598Z</atom:updated>
            <content:encoded><![CDATA[<p>Now that we have working sub-URIs projects thanks to Passsenger &amp; Nginx, let’s install a Gitlab instance, on another subdomain<em>: gitlab.example.com</em></p><p><a href="https://about.gitlab.com/">Gitlab</a> has everything packaged, so when you install it for the forst time, it runs on its own <a href="http://nginx.org/">Nginx</a>, with its own unicorn.<br>It’s cool, but when you want to customize things a bit, it can get scary although it’s simple and the <a href="http://doc.gitlab.com/omnibus/">documentation</a> pretty good.</p><h4>Domain URL</h4><p>Once the installation done, you have a file existing at: <em>/etc/gitlab/gitlab.rb</em></p><p>Editing this file will let you customize a lot of things, including the URL it will be served on:</p><pre>external_url &quot;http://gitlab.example.com&quot;</pre><h4>IPs, ports,</h4><p>The trick is that by default Gitlab will listen to requests from any IP, on the default ports (80, 443). <br>Wich is not so cool when you have <a href="https://medium.com/@gdurelle/rails-apps-on-sub-uris-thanks-to-passenger-817c6ad262db#.tu2b5rckc">other applications</a> running on the same server !</p><pre>nginx[‘listen_addresses’] = [‘127.0.0.1’, “[::1]”]<br>nginx[‘listen_port’] = 8081 <br>nginx[‘custom_gitlab_server_config’] = “location ^~/.well-known {\n alias /opt/gitlab/embedded/service/gitlab-rails/public/.well-known;\n}\n”</pre><ol><li>First we do is re-using our Nginx server as a proxy for Gitlab. Consequence is listening to the whole world becomes useless, so on the first line above, I restrict adresse to localhost (of my server)</li><li>Then I change the port the Gitlab’s nginx serves the application, because 80 and 443 are the default for web application only our Nginx proxy should use them (for the outer world).<br>Port 8080 is already taken by Gitlab’s unicorn. So here I grab the next one (wich is free)</li><li>The thid line is to put in correlation with a <a href="https://medium.com/@gdurelle/let-s-encrypt-164fcbbc12c0#.a1yj13pvy">previous article</a> where I use <a href="https://letsencrypt.org/">Let’s Encrypt</a> as a TLS certificate provider.<br>You’ll understand more in the next Nginx section.</li></ol><p>Once <em>gitlab.rb</em> configuraiton is done you’ll need to:</p><pre>sudo gitlab-ctl reconfigure</pre><p>To let Gitlab reparameterize itself and its internal Nginx with theses new parameters.</p><h4>Nginx</h4><p>Now we need to tell our frontal Nginx proxy to handle external requests for our Gitlab and redirect them to Gitlab’s internal Nginx server.</p><p>Open a new file in /etc/nginx/sites-available/gitlab_proxy :</p><pre>server {<br> listen *:80 default_server;<br> listen [::]:80 ipv6only=on default_server;<br> server_name gitlab.example.com;<br> return 301 https://$server_name$request_uri;</pre><pre> access_log /var/log/nginx/gitlab_access.log;<br> error_log /var/log/nginx/gitlab_error.log;<br>}</pre><pre>server{<br> listen 0.0.0.0:443 ssl default_server;<br> listen [::]:443 ipv6only=on ssl default_server;<br> server_name gitlab.example.com;<br> server_tokens off;</pre><pre> location ~ /.well-known {<br>  allow all;<br> }</pre><pre>location /{<br>  proxy_pass <a href="http://localhost:8081/">http://localhost:8081</a>;<br>  proxy_redirect off;<br>  proxy_set_header Host $http_host;<br>  proxy_set_header X-Real-IP $remote_addr;<br>  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>  proxy_set_header X-Forwarded-Proto $scheme;<br>  proxy_set_header X-Forwarded-Protocol $scheme;<br>  proxy_set_header X-Url-Scheme $scheme;<br> }<br>}</pre><p>The first server block is the usual HTTP redirecting to HTTPS.<br>I customized the logs to keep gitlab’s log from my other domains logs, but you do not have to do that. That’s puerely confirm for me. Not mandated.</p><p>The second server block defines TLS configration, the usual port, same domain etc.<br>Difference comes from teh 2 locations:</p><ol><li><em>.well-known</em> is specific to let’s Encrypt and needed for certificates renewall</li><li>The second does the redirection trick to the internal Nginx.<br>Note how we give the specific port defined earlier so it find the proper application as several can be served on localhost, but on different ports.</li></ol><p>Do not forget to create the symlink to <em>/etc/nginx/sites-enabled</em> and restart nginx ;)</p><p><strong>If I forgot anything, or got wrong or more complicated than needed, please tell me ! I’m always eager to learn a better way :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5245476747fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s encrypt]]></title>
            <link>https://medium.com/@gdurelle/let-s-encrypt-164fcbbc12c0?source=rss-a051fde7b12d------2</link>
            <guid isPermaLink="false">https://medium.com/p/164fcbbc12c0</guid>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Gregory Durelle]]></dc:creator>
            <pubDate>Fri, 11 Mar 2016 14:41:36 GMT</pubDate>
            <atom:updated>2016-03-11T14:47:53.481Z</atom:updated>
            <content:encoded><![CDATA[<p>Many articles have already covered how the <a href="https://letsencrypt.org/">Let’s Encrypt</a> initiative is amazing, easy to install and FREE, and fast to install. I was waiting till my certificates got renewed so I was sure this article will be complete.</p><p>This every steps: from install to renewall. Most of it comes from the <a href="https://letsencrypt.org/getting-started/">Getting Started</a> section, the amazing <a href="http://savagedlight.me/">http://savagedlight.me</a> blog and the <a href="https://letsencrypt.readthedocs.org/en/latest/using.html#installation">Let’s Encrypt user guide</a>.</p><p>For all of this you need to be <em>root</em> on the server. Yes you do.</p><ol><li>Install</li><li>Configuration file</li><li>Certificates &amp; nginx</li><li>Renewall: script + cronjob</li></ol><h4>Install</h4><p>Be sure to be <em>root</em> to use LetsEncrypt. It needs to be able to create directories, files, generate keys, make and listen to requests, etc.</p><pre>git clone <a href="https://github.com/letsencrypt/letsencrypt">https://github.com/letsencrypt/letsencrypt</a><br>cd letsencrypt</pre><h4>Configuration file</h4><p>This will automatize options to the certificates generations.</p><p>Create a cli.ini in the letsencrypt folder:</p><pre>rsa-key-size = 4096</pre><pre># Let’s Encrypt will send you emails to remind you of renewall, in case of.<br> email = <a href="/service/mailto:gdurelle@protonmail.ch">youraddress@protonmail.ch</a></pre><pre># Uncomment to use a text interface instead of ncurses<br># text = True</pre><pre># auto-agree to terms of service. Needed for automatic renewal.<br>agree-tos</pre><pre># Uncomment to use the standalone authenticator on port 443<br># authenticator = standalone<br># standalone-supported-challenges = tls-sni-01</pre><pre># Uncomment to use the webroot authenticator. <br> authenticator = webroot</pre><pre># Replace webroot-path with the path to the public_html / webroot folder being served by your webserver.<br>webroot-path = /srv/www/yourproject/current/public/<br>domains = projects.yourdomain.com</pre><h4>Certificates &amp; nginx</h4><p>Now it’s time to run:</p><pre>./letsencrypt-auto --help</pre><p>Let’sEncrypt will make requests back and forth to authenticate your certificates so of course you need a small configuration inside Nginx.</p><p>Inside your current Nginx’s website <em>server</em> bloc definition you just add:</p><pre>location ~ /.well-known {<br>  allow all;<br>}</pre><p>And make sure this path exists:</p><p><em>wherethehellyouputyourwebsites/.well-known/acme-challenge/</em></p><p>For me it’s: <em>/srv/www/projects/.well-known/acme-challenge/ </em>for example.</p><p>For the TLS specifics use the parameters suggested by: <a href="https://mozilla.github.io/server-side-tls/ssl-config-generator/">https://mozilla.github.io/server-side-tls/ssl-config-generator/</a></p><p>Do use HSTS, Do use OCSP Stapling.</p><h4>Renewall: script + cronjob</h4><p>First create a letsencrypt_renew.sh at you root home:</p><pre>#!/bin/sh<br># Copyright (c) 2015 Marie Helene Kvello-Aune (marieheleneka at gmail dot com; <a href="http://savagedlight.me/">http://savagedlight.me</a>)<br># <br># Permission is hereby granted, free of charge, to any person obtaining a copy<br># of this software and associated documentation files (the “Software”), to deal<br># in the Software without restriction, including without limitation the rights<br># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br># copies of the Software, and to permit persons to whom the Software is<br># furnished to do so, subject to the following conditions:<br># <br># The above copyright notice and this permission notice shall be included in<br># all copies or substantial portions of the Software.<br># <br># THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN<br># THE SOFTWARE.<br>#</pre><pre># This script will check if the specified certificate will<br># expire in 14d or less and if so, instruct let’s encrypt to renew it.<br># It will also reload the configured webserver if certificate is renewed.</pre><pre>#<br># Start of configuration<br>#<br>LETSENCRYPTSERVER=’<a href="https://acme-v01.api.letsencrypt.org/directory&#39;">https://acme-v01.api.letsencrypt.org/directory&#39;</a><br>DOMAINS=”-d projects.yourdomain.com”<br>#DIR=/srv/www/projects/<br>DIR=/usr/share/nginx/html</pre><pre># Probably don’t need to edit below here<br>OPENSSL=”/usr/bin/openssl”<br>LETSENCRYPT=”/root/letsencrypt/letsencrypt-auto”<br># It’s good enough to reload nginx. Other webservers may require restart.<br>RELOADWEBSERVER=”/usr/sbin/service nginx restart”</pre><pre>#<br># End of configuration.<br>#</pre><pre>#<br># !!! DO NOT EDIT BELOW HERE !!!<br>#</pre><pre>alias errecho=’&gt;&amp;2 echo’</pre><pre>if [ “$1” ]<br>then<br> if [ ! -f “$1” ]<br> then<br> errecho “First argument must be path to a certificate file. Non-file path provided.”<br> exit<br> fi<br>else<br> errecho “First argument must be path to a certificate file. No argument provided.”<br> exit<br>fi</pre><pre>if $OPENSSL x509 -checkend 1209600 -noout -in $1<br>then<br> echo “Good for another 14 days!”<br>else<br> mkdir -p $DIR<br> chown -R www-data:www-data $DIR<br> $LETSENCRYPT certonly — renew — server $LETSENCRYPTSERVER -a webroot — webroot-path=$DIR — agree-tos $DOMAINS<br> echo “Certificate should be renewed now. Re-testing…”<br> if $OPENSSL x509 -checkend 1209600 -noout -in $1<br> then<br> echo “Certificate was successfully renewed! Telling webserver…”<br> $RELOADWEBSERVER<br> else<br> errecho “Certificate failed to renew.”<br> exit<br> fi<br>fi</pre><p>Now we’re gonna run this script every month so that it will renew our certificate when needed:</p><pre>0 0 1 * 0 ~/letsencrypt_renew.sh /etc/letsencrypt/live/projects.example.com/fullchain.pem &gt; /dev/null</pre><p>That’s pretty much it.</p><p>Of course: DO READ THE DOCUMENTATION.</p><p>It must have been far more complete now that it was when I struggled on it.</p><p><strong>If I forgot anything, or got wrong or more complicated than needed, please tell me ! I’m always eager to learn a better way :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=164fcbbc12c0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails apps on sub-URIs thanks to Passenger]]></title>
            <link>https://medium.com/@gdurelle/rails-apps-on-sub-uris-thanks-to-passenger-817c6ad262db?source=rss-a051fde7b12d------2</link>
            <guid isPermaLink="false">https://medium.com/p/817c6ad262db</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Gregory Durelle]]></dc:creator>
            <pubDate>Mon, 07 Mar 2016 13:15:25 GMT</pubDate>
            <atom:updated>2016-03-13T14:04:02.479Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p><a href="https://www.phusionpassenger.com/">Phusion Passenger</a> offers a trivial feature but yet impossible to do without it: Applications served on sub-uris on the same subdomain.</p><ul><li><em>projects.example.com/myproject</em></li><li><em>projects.example.com/my_other_project</em></li></ul><p>Of course you need to install passenger first:<a href="https://www.phusionpassenger.com/library/"> https://www.phusionpassenger.com/library</a></p><p><a href="https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/nginx/oss/trusty/install_passenger.html">I suggest you install its custom Nginx integrated version in order to use it for other purpuses without hassle.</a></p><p>Now that Passenger is installed, create a <strong>projects</strong> file in <strong><em>/etc/nginx/sites-available</em></strong></p><h4>Nginx : projects.example.com</h4><p>Paste this (and customize it of course) in the <strong>projects</strong> file:</p><pre>server {<br> listen *:80;<br> listen [::]:80;<br> server_name projects.example.com;<br> server_tokens off;<br> return 301 <a href="https://$server_name$request_uri/">https://$server_name$request_uri</a>;<br>}</pre><pre>server {<br> listen 0.0.0.0:443 ssl;<br> listen [::]:443; <br> server_name projects.example.com;<br> server_tokens off;</pre><pre> # passenger_enabled on;</pre><pre> location ~ ^/<em>myproject</em>(/.*|$) {<br>   alias /srv/www/<em>myproject</em>/current/public$1;</pre><pre>   passenger_base_uri /<em>myproject</em>;<br>   passenger_app_root /srv/www/<em>myproject</em>/current;<br>   passenger_document_root /srv/www/<em>myproject</em>/current/public;<br>   passenger_enabled on;<br> }</pre><pre> location ~ ^/<em>my_other_project</em>(/.*|$) {<br>  alias /srv/www/<em>my_other_project</em>/current/public$1;<br> <br>  passenger_base_uri /<em>my_other_project</em>;<br>  passenger_app_root /srv/www/<em>my_other_project</em>/current;<br>  passenger_document_root /srv/www/<em>my_other_project</em>/current/public;<br>  passenger_enabled on;<br> }</pre><pre> client_max_body_size 250m;</pre><pre> ssl on;<br><br> ssl_certificate /etc/letsencrypt/live/projects.example.com/fullchain.pem; <br> ssl_certificate_key /etc/letsencrypt/live/projects.example.com/privkey.pem; <br> ssl_session_timeout 1d;<br> ssl_session_cache shared:SSL:50m;<br> ssl_session_tickets off;<br> ssl_dhparam /etc/nginx/ssl/certs/dhparam.pem;<br> add_header Strict-Transport-Security “max-age=15768000;<br> includeSubDomains”;</pre><pre> error_page 502 /502.html;<br>}</pre><p>The tricks are:</p><ul><li>Do <strong>not</strong> enable passenger in the server block.</li><li>Do enable passenger for each location block.</li><li>Use <strong>alias</strong> instead of root on the location blocks.</li></ul><p>To test if your configuration is ok:</p><pre>sudo service nginx -t</pre><p>When ready create the symlink in <strong><em>/etc/nginx/sites-enabled</em></strong> and restart nginx</p><pre>sudo service nginx restart</pre><p><strong>DONE !</strong></p><p>You might have noticed lot of other unrelated fields in our Nginx configuration file. It’s the configuration as suggested by Mozzila’s TLS <a href="https://mozilla.github.io/server-side-tls/ssl-config-generator/">configuration config generator</a>.</p><p>I’ll explain more about these in a later post.</p><h4>Nginx.conf</h4><p>In case you need it, here is the major part of my /etc/nginx/nginx.conf file:</p><pre>http {</pre><pre> ##<br> # SSL Settings<br> ##<br> ssl_prefer_server_ciphers on;<br> ssl_protocols TLSv1.1 TLSv1.2;<br> ssl_ciphers ‘ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK’;</pre><pre> # OCSP Stapling<br> ssl_stapling on;<br> ssl_stapling_verify on;</pre><pre> ##<br> # Phusion Passenger config<br> ##<br> # Uncomment it if you installed passenger or passenger-enterprise<br> ##<br> passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;<br> passenger_ruby /home/gdurelle/.rbenv/versions/2.2.3/bin/ruby;<br>}</pre><p><strong>There will be more in yours !</strong> I removed some configs (basics, logs, hosts includes, gzip, etc) for reading purposes, they DO exists in the real config file, so <strong>do not</strong> erase lines you do not see here ;)</p><p>Again, the SSL lines you can see here comes from Mozilla’s generator, I placed them in the <em>nginx.conf </em>file so that all other nginx sites-enabled configs will inherit form it.</p><h4>The Ruby on Rails application</h4><p>The only thing you have to add in your Rails application is in the <em>environnement/production.rb</em> file:</p><pre>config.action_controller.relative_url_root = “/myproject”</pre><p>Thus the generated URLs will be right.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=817c6ad262db" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>