NGINX Drupal 7 Conf

by Andrew Maestro

HTML

# Enable compression, this will help if you have for instance advagg‎ module
    # by serving Gzip versions of the files.
    gzip_static on;

    client_max_body_size 120m;
    fastcgi_read_timeout 600;

    if ($host = 188.226.133.245) {
            return 301 $scheme://arleysign.com$request_uri;
    }

    if ($host = arleysign.net) {
            return 301 $scheme://arleysign.com$request_uri;
    }

    if ($host ~* ^www\.(.*)$) {
            return 301 $scheme://$1$request_uri;
    }

    location = /favicon.ico {
            log_not_found off;
            access_log off;
    }

    location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
    }

    # This matters if you use drush prior to 5.x
    # After 5.x backups are stored outside the Drupal install.
    #location = /backup {
    #        deny all;
    #}

    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
            allow 192.168.0.0/16;
            deny all;
    }

    location ~ \..*/.*\.php$ {
            return 403;
    }

    # No no for private
    location ~ ^/sites/.*/private/ {
            return 403;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
            return 403;
    }

    location / {
            # This is cool because no php is touched for static content
            try_files $uri @rewrite;
    }

    location @rewrite {
            # You have 2 options here
            # For D7 and above:
            # Clean URLs are handled in drupal_environment_initialize().
            rewrite ^ /index.html last;
            # For Drupal 6 and bwlow:
            # Some modules enforce no slash (/) at the end of the URL
            # Else this rewrite block wouldn't be needed (GlobalRedirect)
           ...