Commit 4d549118 authored by Adrian Rossouw's avatar Adrian Rossouw

Commit omega8cc's patch for the new config file format. it generates the files...

Commit omega8cc's patch for the new config file format. it generates the files correctly for me now (it seems).
parent dc26874f
......@@ -9,6 +9,7 @@ class provisionService_http_nginx extends provisionService_http {
function init() {
$this->server->nginx_conf_path = $this->server->config_path . '/nginx/nginx.d';
$this->server->nginx_site_conf_path = $this->server->config_path . '/nginx/vhost.d';
$this->server->setProperty('restart_cmd', _provision_default_restart_cmd());
}
......@@ -57,10 +58,15 @@ class provisionService_http_nginx extends provisionService_http {
}
function parse_configs() {
return TRUE;
// apparently nginx doesnt need this.
// This is required to be configurable, due to the fact that different
// hosts might need to do this differently.
if ($this->server->shell_exec($this->server->restart_cmd)) {
drush_log(dt('Nginx on %server has been restarted', array('%server' => $this->server->remote_host)));
}
else {
drush_log(dt('Web server %server could not be restarted. Changes might not be available until this has been done. (error: %msg)', array('%server' => $this->server->remote_host, '%msg' => join("\n", drush_shell_exec_output()))), 'warning');
}
}
}
......@@ -85,6 +91,7 @@ class provisionConfig_nginx_server extends provisionConfig_nginx {
public $description = 'nginx server configuration file';
function filename() {
dlm($this->data['server']);
return $this->data['server']->config_path . '/nginx.conf';
}
......
# Aegir web server configuration file
#######################################################
### nginx.conf main
#######################################################
#
pid /var/run/nginx.pid;
user www-data www-data;
worker_processes 4;
worker_rlimit_nofile 8192;
events {
worker_connections 4096;
use epoll;
}
http {
## MIME types
include /etc/nginx/fastcgi_params;
include /etc/nginx/mime.types;
default_type application/octet-stream;
## Size Limits
client_body_buffer_size 1k;
client_header_buffer_size 1k;
client_max_body_size 10m;
large_client_header_buffers 3 3k;
connection_pool_size 256;
request_pool_size 4k;
server_names_hash_bucket_size 128;
## Timeouts
client_body_timeout 60;
client_header_timeout 60;
keepalive_timeout 75 20;
send_timeout 60;
## General Options
ignore_invalid_headers on;
limit_zone gulag $binary_remote_addr 1m;
recursive_error_pages on;
sendfile on;
## TCP options
tcp_nodelay on;
tcp_nopush on;
## Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 9;
gzip_http_version 1.1;
gzip_min_length 10;
gzip_types text/plain text/css image/png image/gif image/jpeg application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;
gzip_vary on;
gzip_static on;
gzip_proxied any;
gzip_disable "MSIE [1-6]\.";
## Log Format
log_format main '"$remote_addr" $host [$time_local] '
'"$request" $status $body_bytes_sent '
'$request_length $bytes_sent "$http_referer" '
'"$http_user_agent" $request_time "$gzip_ratio"';
client_body_temp_path /var/cache/nginx/client_body_temp 1 2;
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log crit;
#######################################################
### nginx default server
#######################################################
server {
<?php if (is_array($server->web_ports)) :
foreach ($server->web_ports as $web_port) :?>
NameVirtualHost *:<?php print $web_port; ?>
<VirtualHost *:<?php print $web_port; ?>>
ServerName default
Redirect 404 /
</VirtualHost>
listen <?php print $web_port; ?>;
<?php
endforeach;
endif;
?>
<IfModule !env_module>
LoadModule env_module modules/mod_env.so
</IfModule>
server_name _;
location / {
root /var/www/nginx-default;
index index.html index.htm;
}
<IfModule !rewrite_module>
LoadModule rewrite_module modules/mod_rewrite.so
</IfModule>
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
# virtual hosts
Include <?php print $apache_site_conf_path ?>
}
# platforms
Include <?php print $apache_platform_conf_path ?>
#######################################################
### nginx virtual domains
#######################################################
# other configuration, not touched by aegir
Include <?php print $apache_conf_path ?>
# virtual hosts
include <?php print $nginx_site_conf_path ?>/*;
# other configuration, not touched by aegir
include <?php print $nginx_conf_path ?>/*;
<?php print $extra_config; ?>
}
<VirtualHost *:<?php print $this->site_port; ?>>
<?php if ($this->site_mail) : ?>
ServerAdmin <?php print $this->site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $this->root; ?>
ServerName <?php print $this->uri; ?>
#######################################################
### nginx.conf site start
#######################################################
SetEnv db_type <?php print urlencode($db_type); ?>
server {
listen <?php print $this->site_port; ?>;
server_name <?php print $this->uri; ?> <?php if (!$this->redirection && is_array($this->aliases)) : foreach ($this->aliases as $alias_url) : if (trim($alias_url)) : ?> <?php $alias_url = "." . $alias_url; ?> <?php print $alias_url; ?> <?php endif; endforeach; endif; ?>;
root <?php print $this->root; ?>;
index index.php index.html;
SetEnv db_name <?php print urlencode($db_name); ?>
## Deny some crawlers
if ($http_user_agent ~* (HTTrack|HTMLParser|libwww) ) {
return 444;
}
## www. redirect
# if ($host ~* ^(www\.)(.+)) {
# set $rawdomain $2;
# rewrite ^/(.*)$ http://$rawdomain/$1 permanent;
# }
## 6.x starts
location / {
try_files $uri @cache;
}
SetEnv db_user <?php print urlencode($db_user); ?>
location @cache {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @drupal;
add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
add_header X-Header "Boost Citrus 1.9";
charset utf-8;
try_files /cache/normal/$host${uri}_$args.html @drupal;
}
SetEnv db_passwd <?php print urlencode($db_passwd); ?>
location @drupal {
###
### now simplified to reduce rewrites
###
rewrite ^/(.*)$ /index.php?q=$1 last;
}
SetEnv db_host <?php print urlencode($db_host); ?>
location ~* (/\..*|settings\.php$|\.(htaccess|engine|inc|info|install|module|profile|pl|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(Entries.*|Repository|Root|Tag|Template))$ {
deny all;
}
<?php if (!$this->redirection && is_array($this->aliases)) :
foreach ($this->aliases as $alias_url) :
if (trim($alias_url)) : ?>
ServerAlias <?php print $alias_url; ?>
location ~* /(files|themes|sites)/.*\.php$ {
return 444; ### deny php here
}
location ~* ^/sites/(.*)/files/backup_migrate/ {
return 444; ### deny direct access
}
location ~ \.php$ {
try_files $uri @drupal; ### check for existence of php file
fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
<?php
endif;
endforeach;
endif; ?>
location ~ \.css$ {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @uncached;
access_log off;
expires max; #if using aggregator
add_header X-Header "Boost Citrus 2.1";
try_files /cache/perm/$host${uri}_.css $uri =404;
}
location ~ \.js$ {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @uncached;
access_log off;
expires max; # if using aggregator
add_header X-Header "Boost Citrus 2.2";
try_files /cache/perm/$host${uri}_.js $uri =404;
}
location ~ \.json$ {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @uncached;
access_log off;
expires max; ### if using aggregator
add_header X-Header "Boost Citrus 2.3";
try_files /cache/normal/$host${uri}_.json $uri =404;
}
location @uncached {
access_log off;
expires max; # max if using aggregator, otherwise sane expire time
}
<?php print $extra_config; ?>
location ~* /(files/imagecache)|(fckeditor)|(ckeditor)/ {
access_log off;
expires 30d;
try_files $uri @drupal; ### imagecache and (f)ckeditor support
}
# Error handler for Drupal > 4.6.7
<Directory "<?php print $this->site_path; ?>/files">
SetHandler This_is_a_Drupal_security_line_do_not_remove
</Directory>
location ~* ^.+\.(jpg|jpeg|gif|png|ico|swf)$ {
access_log off;
expires 30d;
try_files $uri =404;
}
</VirtualHost>
location ~* \.xml$ {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @drupal;
add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
add_header X-Header "Boost Citrus 2.4";
charset utf-8;
types { }
default_type application/rss+xml;
try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html $uri @drupal;
}
location ~* /feed$ {
if ( $request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_cookie ~ "DRUPAL_UID") {
return 405;
}
error_page 405 = @drupal;
add_header Expires "Tue, 24 Jan 1984 08:00:00 GMT";
add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
add_header X-Header "Boost Citrus 2.5";
charset utf-8;
types { }
default_type application/rss+xml;
try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html $uri @drupal;
}
} # end of server
#######################################################
### nginx.conf site end
#######################################################
<?php
if ($this->redirection) {
require(dirname(__FILE__) . '/http/apache/vhost_redirect.tpl.php');
}
<VirtualHost *:80>
<?php if ($this->site_mail) : ?>
ServerAdmin <?php print $this->site_mail; ?>
<?php endif;?>
DocumentRoot <?php print $this->root; ?>
ServerName <?php print $this->uri; ?>
server {
listen 80;
server_name <?php print $this->uri; ?> <?php if (is_array($this->aliases)) : foreach ($this->aliases as $alias_url) : if (trim($alias_url)) : ?> <?php $alias_url = "." . $alias_url; ?> <?php print $alias_url; ?> <?php endif; endforeach; endif; ?>;
root <?php print $this->root; ?>;
index index.php index.html;
<?php if (is_array($this->aliases)) :
foreach ($this->aliases as $alias) : ?>
ServerAlias <?php print $alias; ?>
<?php
endforeach;
endif; ?>
location / {
root /var/www/nginx-default;
index index.html index.htm;
# rewrite ^/(.*)$ http://<?php print $this->uri ?>/$1 permanent;
rewrite ^/(.*)$ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>? permanent;
}
RewriteEngine on
# the ? at the end is to remove any query string in the original url
RewriteRule ^(.*)$ <?php print $this->platform->server->web_disable_url . '/' . $this->uri ?>?
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
</VirtualHost>
}
<VirtualHost *:<?php print $this->site_port; ?>>
<?php if ($this->site_mail) : ?>
ServerAdmin <?php print $this->site_mail; ?>
<?php endif;?>
server {
listen <?php print $this->site_port; ?>;
server_name <?php print $this->uri; ?> <?php if (!$this->redirection && is_array($this->aliases)) : foreach ($this->aliases as $alias_url) : if (trim($alias_url)) : ?> <?php $alias_url = "." . $alias_url; ?> <?php print $alias_url; ?> <?php endif; endforeach; endif; ?>;
root <?php print $this->root; ?>;
index index.php index.html;
<?php if (is_array($this->aliases) && count($this->aliases)): ?>
ServerName <?php print array_pop($this->aliases); ?>
<?php if (count($this->aliases)): ?>
ServerAlias <?php print join(" ", $this->aliases); ?>
<?php endif; ?>
<?php else:
# this should never happen and has the potential of creating an infinite redirection loop
?>
ServerName <?php print $this->uri ?>
<?php endif; ?>
location / {
root /var/www/nginx-default;
index index.html index.htm;
<?php if ($ssl_redirect): ?>
rewrite ^/(.*)$ https://<?php print $this->uri ?>/$1 permanent;
<?php else: ?>
rewrite ^/(.*)$ http://<?php print $this->uri ?>/$1 permanent;
<?php endif; ?>
}
<?php if ($ssl_redirect): ?>
RedirectMatch permanent ^(.*) https://<?php print $this->uri ?>$1
<?php else: ?>
RedirectMatch permanent ^(.*) http://<?php print $this->uri ?>$1
<?php endif; ?>
</VirtualHost>
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/nginx-default;
}
}
......@@ -238,6 +238,10 @@ function drush_provision_verify() {
function _provision_default_restart_cmd() {
$command = '/usr/sbin/apachectl'; // A proper default for most of the world
// Try to detect the nginx restart command first
$options[] = '/etc/init.d/nginx'; // nginx on debian
foreach (explode(':', $_SERVER['PATH']) as $path) {
$options[] = "$path/apache2ctl";
$options[] = "$path/apachectl";
......@@ -255,7 +259,12 @@ function _provision_default_restart_cmd() {
}
}
return "sudo $command graceful";
if(preg_match("/(nginx)/", $command)) {
return "sudo $command reload";
}
else {
return "sudo $command graceful";
}
}
function _provision_default_web_group() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment