Nginx virtual server configuration for Drupal
server { | |
server_name example.com; ## <-- Your domain. | |
root /webapps/example-drupal; ## <-- Path to your Drupal files. | |
# Enable compression, this will help if you have for instance advagg module | |
# by serving Gzip versions of the files. | |
gzip_static on; | |
location / { | |
try_files $uri @rewrite; | |
} | |
location @rewrite { | |
rewrite ^ /index.php; | |
} | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
fastcgi_intercept_errors on; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; ## <-- location of the PHP-FPM socket | |
} | |
location = /favicon.ico { | |
log_not_found off; | |
access_log off; | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
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 ~ ^/sites/.*/files/styles/ { | |
try_files $uri @rewrite; | |
} | |
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { | |
expires max; | |
log_not_found off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment