Skip to content

Nginx Includes

Custom Nginx directives can be powerful tools. Stratus makes it easy to add includes.

Nginx includes are easy to add in Stratus, but can be difficult to master. Incorrectly coded includes can result in undesirable results and should never be added to a Production instance without fully testing on another environment.

The following are two examples provided by MageMojo customers. Do not use these as-is on a Production environment and always test all includes on a non-Production environment before deploying.

WordPress

Add this to get WordPress working in a subdirectory of your web-root, substituting the blog path for the particular sub-directory.

location /blog/ {
index index.php index.html index.htm;
try_files $uri $uri/ /blog/index.php?$args ;
location ~* \.php$ { try_files /dummy @proxy; }
}

location /blog/wp-admin/ {
index index.php index.html index.htm;
try_files /blog/wp-admin/$uri /blog/wp-admin/$uri/ /blog/wp-admin/index.php?$args ;
location ~* \.php$ { try_files /dummy @proxy; }
}

Custom PHP Scripts

The default Stratus Nginx template does not allow PHP execution in directories not required by Magento. A special Nginx location is required if you have custom scripts or other PHP based code you need to run.

location ~* my_custom_scripts/ {
try_files $uri $uri/ /index.php?$args;
location ~* \.php$ { try_files /dummy @proxy; }
}

ChangeĀ my_custom_scripts in the example above to match your requirements.