Stuff I'm Up To

Technical Ramblings

Nginx, Not Just a Web Server — October 26, 2016

Nginx, Not Just a Web Server

Nginx is capable of more than serving web pages. It can load balance, cache and act as a reverse proxy.

We recently had need to access two web services on the same server through a single interface. This is where the reverse proxy came in.

  • Service A runs on port 9010
  • Service B runs on port 9020
  • Access to both services needs to be via a single front end using traditional http over port 80

Not ideal, but it’s not my system design, just a challenge we need to face. The way we tackled it was using an Nginx reverse proxy and split the calls to specific URL paths on each web service to the relevant underlying back end service.

Continue reading

Comodo SSL Certs & Android — October 10, 2016

Comodo SSL Certs & Android

After buying a cheap SSL certificate I found I’d missed something important during the install.

Usually it’s just a case of copy the certificate and key files to /etc/ssl/certs and /etc/ssl/private, respectively and then pointing the Nginx config at them to get it working.

Well all was well in the GUI world of Linux and Windows browsers. But My Android said the certificate wasn’t trusted. Looks like there’s some CA intermediates that need sorting.

Continue reading

NGINX, PHP and a Blank Page — September 29, 2016
Nginx 1.10 and PHP7.0-fpm — September 23, 2016

Nginx 1.10 and PHP7.0-fpm

Keen to press on a try new suff I figured that seeing as I’d now tried Nginx 1.10 that I’d put that together with PHP 7.0.

I started of by thinking I’d remove nginx 1.6 from my workstation, clean the config out and install the latest from the nginx repository. It was all going so well until:

Unpacking nginx (1.10.1-1~jessie) ...
dpkg: error processing archive /var/cache/apt/archives/nginx_1.10.1-1~jessie_amd64.deb (--unpack):
 trying to overwrite '/usr/share/nginx/html/index.html', which is also in package nginx-common 1.6.2-5+deb8u2
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/nginx_1.10.1-1~jessie_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Continue reading

ownCloud — September 20, 2016

ownCloud

We needed a semi-secure method of transferring files between staff and 3rd parties. To handle those frequent times when someone tries to attach a 150MB file onto an email. OwnCloud to the rescue.

It’s come a long way since I first used it. Now it has all kinds of plugins and features. What’s good about it is there are clients for pretty much all platforms – many free. Failing that good old HTML will do.

Continue reading

NGINX and php5-fpm —

NGINX and php5-fpm

This new version of NGINX is tending to be a bit of a pain in terms of installation. Gone are the sites-available and sites-enabled folders and it does a couple of things during installation that really grips my goat.

Getting php5-fpm working with it needs some manipulation of the config. The site configs are now located under /etc/nginx/conf.d/ and they now have a .conf extension. The default being default.conf.

By default this config sticks the ‘root’ directive under the location /. Which when it comes to running php5-fpm and using fastcgi parameters causes a headache. It’s a simple fix, but put simply the previous use of $document_root will not work because the directive needs to be within the server context NOT location.

Continue reading

NGINX and Laravel —

NGINX and Laravel

NGINX needs a little special setup to handle Laravel as Laravel only really serves one page. All others are served through index.php as a route.

index index.php;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying index.php.
    try_files $uri $uri/ /index.php$query_string;
}

They key parts here are serve index.php as the index page and then using try files when it can’t find $uri serve up index.php and pass the $query_string as the parameters.

Continue reading

NGINX —

NGINX

Absolutely my favourite web server. Small footprint and very fast to get running.

First add the repositories to your Debian sources by creating the file /etc/apt/sources.list.d/nginx.list

deb http://nginx.org/packages/debian/ jessie nginx
deb-src http://nginx.org/packages/debian/ jessie nginx

Change the release name as necessary.

Then find the ID of the key the repo is signed with so you can add it to the apt key store.

$ sudo apt-get update

You should see you get a GPG error with the ID of the key you need. Copy this and paste it into the next command to download and install it:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys [KEYID]

Job done now just apt update and install.

Source: https://www.nginx.com/resources/wiki/start/topics/tutorials/install/