Top Nav

Archive | Nginx

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.

 

0

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:

0

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:

https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag?csw=1

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.

0

Plesk 11 – vhost.conf File For Nginx

We’re all familier with using a vhost.conf file on Plesk to provide custom Apache directives to an individual virtual host. Originally the file was located at:

Recent versions of Plesk have moved the file to:

And of course there is an SSL version of the file at:

The good news is there’s also now a file for Nginx at:

By default these files don’t exist and are not included in the configuration. So you’ll need to create the file and then run:

or

 

0

Increase Nginx Upload Limit On Server With Plesk Panel

From the Plesk Panel you can set the PHP upload_max_filesize at Website & Domains -> PHP Setting. But if you’re using Nginx then you may also need to configure Nginx to allow larger uploads. We saw errors like this in the /var/log/nginx/error_log:

To resolve the issue edit /etc/nginx/nginx.conf and set client_max_body_size by adding the highlighted line:

 

1