Top Nav

Archive | Nginx

Force HTTP On Nginx

Simple configuration line to redirect HTTPS requests to HTTP:


Enable Compression On Plesk With Nginx

To enable compression on a Plesk server with Nginx handling static content, had to add the following to .htaccess:

This configuration is explained here:

And then in Plesk under:

Subscriptions -> -> Websites & Domains -> Web Server Settings -> Additional nginx directives

added the following:

The Nginx configuration is explained here:


Block XSS on Apache or Nginx

Here are some handy Apache rewrite rules for blocking cross site scripting (XSS) attacks:

And here are similar rules for Nginx:

We gathered these rules from several sources around the net so they are not original but it’s handy to have them all in one place with both the Apache and Nginx versions.



Block Access To .git And .svn Folders

On Nginx add the following to each “server” block:

And the for Apache add the following to the VirtualHost block:


Set X-Robots-Tag Header On Plesk/Nginx

On a Plesk server with Nginx enabled here are the steps to setup custom X-Robot-Tag headers has described here:

In Plesk control panel:

1. Select the domain

2. Click Web Server Settings

3. Scroll down to nginx settings

4. If you have “Serve static files directly by nginx” checked (which I recommend), you’ll need to remove the file extensions to which you’re going to apply headers. In this example remove “pdf” from the list.

5. In the “Additional nginx directives” field enter:

6. Click OK button to save changes.