Pack Hosting Panel

Nginx configuration

Setting up a nginx configuration in your CI/CD pipeline using Hipex Deploy


We treat our server configuration as code. You should do the same with the Nginx configuration specific for your application. This will ensure that changes are visible, trackable and portable. Always the same on every environment.


To ensure Hipex Deploy keeps your Nginx config in sync with your codebase, all you need to do is point it to the Nginx configuration directory. In this case app/etc/nginx.

$nginxConfig = new NginxConfiguration('app/etc/nginx');

All files in the folder app/etc/nginx matching pattern **/*.nginx* will be copied to the domain config folder ~/domains/example.com/var/etc/ and trigger nginx-reload.

Domain specific config

When you have domain specific configurations, the content of your nginx folder needs to reflect this.

Take for example this folder structure:

- app/etc/nginx/
  - example.com/magento-storecode.nginx.conf
  - port-80/https.nginx.conf

When looking at your test environment it would look like this:

- app/etc/nginx/
  - test.example.com/magento-storecode.nginx.conf
  - port-80/https.nginx.conf

There are two ways to solve this. The first would be to create a second NginxConfiguration object and point it to two different directories and attach it to a deployment stage.

$nginxConfigProduction = new NginxConfiguration('app/etc/nginx-production');

$nginxConfigTest = new NginxConfiguration('app/etc/nginx-test');

The second and more convient way would be to simply create a symlink from one folder to the other. So your total folder structure will look like this:

- app/etc/nginx/
  - example.com/magento-storecode.nginx.conf
  - test.example.com -> example.com 
  - port-80/https.nginx.conf

Server role specific

On a cluster, usually you will need different configurations on a load balancer than your app servers. This is also done using multiple Nginx config objects.

$nginxConfigApp = new NginxConfiguration('app/etc/nginx-app');

$nginxConfigLoadBalancer = new NginxConfiguration('app/etc/nginx-test');