How to use Nginx

in Nginx configuration

One of the biggest differences between Hypernode and more traditional platforms, such as Byte’s shared Magento hosting, is the use of Nginx (pronunciation: ‘Engine X’) over Apache. Nginx has much better performance than Apache, and allows us to serve your webshop to many more visitors than Apache would.

Magento specific Nginx configuration

As your Hypernode is designed from the ground up to host Magento, we’ve taken great care to tweak the Nginx server for optimal performance and usability. We’ve moved all the Magento specific settings we’ve learned over the years, and the ones that Magento Inc. suggests, and includes in its .htaccess file, into the main Nginx configuration. Then we added a layer of protection against malicious bots and hackers, and a modern, json based logging format.

Extending Nginx configuration

Nginx does not use .htaccess files like Apache. This means that configuration previously done in .htaccess-files now has to be done in a different format, explained in the nginx documentation.

Custom configuration to nginx can be made by placing files in the nginx-directory inside your home directory. Files which name start with server. will be parsed in the server context of nginx, files that start with http. will be parsed in the http context.

When you make changes in your configuration files in /data/web/nginx a little daemon called the nginx-config-reloader detects changes in the configuration files and checks the syntax of the nginx config.

When configuration files in the nginx-directory cannot be parsed by nginx, a new file is created named nginx_error_output containing the error message from nginx, otherwise the nginx daemon is reloaded to make the changes active.

Some typical scenarios are explained below:

Dos and Don’ts

While you can easily extend the Nginx config yourself, there are a few things you need to keep into consideration. Your Hypernode is designed to host a single Magento installation from the root of its public folder. We don’t advise running non Magento software from the root of your public folder, as the core config assumes there’s a Magento there. While you can easily host, say, a (WordPress) blog in a subdirectory, the reverse (With Magento installed into a subfolder) is not supported. You also shouldn’t add subdomains, virtual hosts, or custom server blocks, as these may conflict with future updates, and we advise not to change the server_name setting, as this may break your SSL settings. If you think you do need to change any of these settings, let us know, and we’ll work with you to get it working in a secure way, if possible.

Don’t use includes in your nginx config in /data/web/nginx as this will break the nginx config after moving the files to its destination by the nginx-config-reloader daemon.

Modern logging

Instead of using the log format used by Apache, or NCSA webservers, we’ve opted to create our access logs in a powerful JSON format. The advantage of this format is that it makes the logs a lot easier to automatically parse, and a lot easier to expand when we want to add more information to them, without breaking existing tools. And speaking of tools, we’ve included a powerful log analyser on your Hypernode, called hypernode-parse-nginx-log, or pnl for short. For more information, see our article on logfiles.