Archive for the nginx Category

Nginx adding http2 support to improve speed

Saturday, September 24th, 2016 | Permalink

Since version 1.9.5 Nginx support http2, which is a major improvement in comparison to http 1.1.

One of the major differences is https by default. If you haven’t enabled your website for https, then I ask you to read thru my short summary on Letsencrypt and how to set it up.

The second thing is an improvement in regards to overall data transfer. http 1.1 was design at a time in which bandwidth was still a problem. Therefor the RFC set a limit of simultanoius connections as written in RFC 2086.

Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion.

Means, that the amounts of files that could be loaded from a single host is limited. With http2 this limit falls and websites load way faster then before.

Nginx has a manual to install http2 which I literally don’t want to copy & paste here.
Read yourself and make the internet faster!

Once you’re done, check if your site really supports http2 by using the http/2 and spdy indicator plugin in Chrome.

Nginx, don’t redirect to https for specific site / url

Saturday, September 24th, 2016 | Permalink

After you have read my article on redirecting all traffic to https, you discovered that some content is not appearing correctly anymore.

For the finance blog I am supporting, this is the case for some pages like “10 goldene Regeln für binaere Optionen” were http content is embedded. In this case it is an external javascript (unfortunately, you should try to avoid this whenever possible) that could not be served using https.

So, we needed an exception to do this.

In your server {} configuration for port 80 (non-ssl) add this:

location ^~ /10-goldene-regeln-fur-den-handel-mit-binaren-optionen {
try_files $uri $uri/ /index.php?$args;
}

In the configuration for port 443 (ssl / https) add this:

location /10-goldene-regeln-fur-den-handel-mit-binaren-optionen {
return 301 http://$server_name$request_uri;
try_files $uri $uri/ /index.php?$args;
}

Of course you need to adjust that for your needs. This overrides the configuration for the redirect all, for an exception with the URL “/10-goldene-regeln-fur-den-handel-mit-binaren-optionen”