|
## |
|
# You should look at the following URL's in order to grasp a solid understanding |
|
# of Nginx configuration files in order to fully unleash the power of Nginx. |
|
# http://wiki.nginx.org/Pitfalls |
|
# http://wiki.nginx.org/QuickStart |
|
# http://wiki.nginx.org/Configuration |
|
# |
|
# Generally, you will want to move this file somewhere, and start with a clean |
|
# file but keep this around for reference. Or just disable in sites-enabled. |
|
# |
|
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. |
|
## |
|
|
|
# Default server configuration |
|
# |
|
server { |
|
listen 80 default_server; |
|
#listen 443 ssl; |
|
listen [::]:80 default_server; |
|
|
|
# SSL configuration |
|
# |
|
# listen 443 ssl default_server; |
|
# listen [::]:443 ssl default_server; |
|
# |
|
# Self signed certs generated by the ssl-cert package |
|
# Don't use them in a production server! |
|
# |
|
# include snippets/snakeoil.conf; |
|
server_name ~^((?<subdomain>.*)\.)(?P<project>.+)\.devel$ ~^(?P<project>.+)\.devel$; |
|
|
|
#ssl on; |
|
#ssl_protocols TLSv1 TLSv1.1 TLSv1.2; |
|
#ssl_certificate /etc/nginx/ssl/nginx.crt; |
|
#ssl_certificate_key /etc/nginx/ssl/nginx.key; |
|
|
|
set $original "${project}.devel"; |
|
|
|
if (-d /home/alexd/www/$project/master/docroot) { |
|
set $project "${project}/master/docroot"; |
|
} |
|
|
|
if (-d /home/alexd/www/$project/docroot) { |
|
set $project "${project}/docroot"; |
|
} |
|
|
|
if (-d /home/alexd/www/$project/web) { |
|
set $project "${project}/web"; |
|
} |
|
|
|
if (-d /home/alexd/www/$project/code) { |
|
set $project "${project}/code"; |
|
} |
|
|
|
if (-d /home/alexd/www/$project/public) { |
|
set $project "${project}/public"; |
|
} |
|
|
|
root /home/alexd/www/$project; |
|
|
|
location = /favicon.ico { |
|
log_not_found off; |
|
access_log off; |
|
} |
|
|
|
location = /misc/favicon.ico { |
|
log_not_found off; |
|
access_log off; |
|
alias /home/alexd/www/favicon/drupal.ico; |
|
} |
|
|
|
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 / { |
|
# 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(). |
|
if (-f /home/alexd/www/$project/index.php) { |
|
rewrite ^ /index.php; |
|
} |
|
if (!-f /home/alexd/www/$project/index.php) { |
|
rewrite ^ /index.html; |
|
} |
|
# For Drupal 6 and below: |
|
# Some modules enforce no slash (/) at the end of the URL |
|
# Else this rewrite block wouldn't be needed (GlobalRedirect) |
|
#rewrite ^/(.*)$ /index.php?q=$1; |
|
} |
|
|
|
#location ~ ^/sites/.*.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ { |
|
# root /home/alexd/www/$project; |
|
#} |
|
|
|
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; |
|
set $sock "unix:/var/run/php/php7.1-fpm.sock"; |
|
set $phpver '7.1'; |
|
if ($http_cookie ~ 'php=5.6') { |
|
set $sock "unix:/var/run/php5-fpm.sock"; |
|
set $phpver '5.6'; |
|
} |
|
if ($http_cookie ~ 'php=7.0') { |
|
set $sock "unix:/var/run/php/php7.0-fpm.sock"; |
|
set $phpver '7.0'; |
|
} |
|
if ($http_cookie ~ 'php=7.1') { |
|
set $sock "unix:/var/run/php/php7.1-fpm.sock"; |
|
set $phpver '7.1'; |
|
} |
|
add_header 'X-PHP-Version' $phpver; |
|
fastcgi_pass $sock; |
|
fastcgi_read_timeout 150; |
|
fastcgi_param SERVER_NAME "${original}"; |
|
fastcgi_buffer_size 64k; |
|
fastcgi_buffers 4 64k; |
|
} |
|
|
|
# Fighting with Styles? This little gem is amazing. |
|
location ~ ^/sites/default/files/styles/ { |
|
log_not_found off; |
|
try_files $uri @rewrite; |
|
} |
|
|
|
location ~ ^/sites/default/files/ { |
|
log_not_found off; |
|
#try_files $uri @rewrite; |
|
} |
|
|
|
location ~* \.(png|jpg|jpeg|gif|ico|woff|otf|ttf|eot|svg|txt|pdf|docx?|xlsx?)$ { |
|
access_log off; |
|
log_not_found off; |
|
} |
|
} |