Posts for Tag: tips

Avoiding SSL redirect loop

If you are configuring an nginx website to use SSL and - by any chance - you need to setup more than one “server” entry (for instance to make www redirect to the plain URL), keep in mind that you need to declare the ssl certificate mumbo-jumbo in both entries, otherwise browsers will enter a redirect loop.

Something like the following will do:

server {
        listen 443 ssl;
        server_name www.zenblast.com;

        include zenblast-ssl.conf;

        return 301 $scheme://zenblast.com$request_uri;
}

server {
        server_name zenblast.com;
        listen              443 ssl;

        include zenblast-ssl.conf;

        ...
}

zenblast-ssl.conf is where we define stuff like ssl_certificate, ssl_certificate_key, ssl on, ssl_ciphers, ssl_prefer_server_ciphers on, and ssl_protocols. Notice that the file is included in both entries.

Hope this helps save someone 30 minutes of Googling :)

'Google Drive new document bookmark'

Here's a neat trick: Bookmarks to create all sorts of Google Drive documents. This way you don't have to first access Google Drive and click on new, you can just have the appropriate bookmarks in your browser's toolbar. Just add these links:

- New Google Document: [https://drive.google.com/document/?action=new](https://drive.google.com/document/?action=new) - New Google Spreadsheet: [https://drive.google.com/spreadsheet/?action=new](https://drive.google.com/spreadsheet/?action=new) - New Google Presentation: [https://drive.google.com/presentation/?action=new](https://drive.google.com/presentation/?action=new)

Have fun documenting :)

Found - a Quicksilver alternative for Mac OSX

If you are looking for an alternative for [Quicksilver](http://www.blacktree.com/), the popular OSX launcher, you might find [Found](https://itunes.apple.com/us/app/found/id527134927?mt=12) (no pun intended) a suitable replacement.

To be honest it does not seem to be quite as powerful but, if - like me - you only use Quicksilver to launch apps, then Found is a great lightweight (and beautiful) alternative.

Nginx rewrite/redirect for blog URL

When i moved my blog to a [middleman](http://middlemanapp.com) system, i found that i needed to provide redirects from `/2012/01/25/some-post` to `/blog/2012/01/25/some-post`. It's a relatively simple task, though i lost some time because i missed a detail that no one usually explains.

There are articles on the web explaining how to do url rewriting in Nginx. Most of them will tell you something like this:

location /2009/ { rewrite ^(/2009/.*)$ /blog$1 break; }

In a gist, that's what you need. What they forget to mention is it will not work unless you provide the *root* in that *location* block.

Another thing you might want to do, to track eventual problems with your regular expression skills (hehe), is activate rewrite logging. It's also a good idea to inform clients that the resource moved permanently (301).

The full solution ended up being:

server { listen 80; server_name pedroassuncao.com *.pedroassuncao.com;

access_log /path/to/your/logs/nginx.access.log; error_log /path/to/your/logs/nginx.error.log;

rewrite_log on;

location /2009/ { root /path/to/your/html/; rewrite ^(/2009/.*)$ /blog$1 break; return 301; }

location / { root /path/to/your/html/; expires 24h; }

error_page 404 /404; }

A final note: When you activate `rewrite_log on;` nginx will dump all rewrite information to your *error* log as a notice. Since notice is the default it will show up. You can always make sure, by adding *notice* after the log file:

error_log /path/to/your/logs/nginx.error.log notice;

Happy nginxing :)