From 3388f9dc65e25ff8aca54127f8c6e3db259e170f Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 13:15:54 +0530 Subject: [PATCH 01/10] bypass nginx-custom installation --- ee/cli/plugins/site_functions.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index be2327ff..bd857691 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -310,7 +310,7 @@ def setupwordpress(self, data): .format(data['ee_db_pass'], "\n\ndefine(\'WP_DEBUG\', false);", redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );" - .format(ee_domain_name) if data['wpredis'] + .format(ee_domain_name) if data['wpredis'] else ''), log=False ): @@ -352,7 +352,7 @@ def setupwordpress(self, data): " true);", "\n\ndefine(\'WP_DEBUG\', false);", redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );" - .format(ee_domain_name) if data['wpredis'] + .format(ee_domain_name) if data['wpredis'] else ''), log=False ): @@ -655,8 +655,18 @@ def site_package_check(self, stype): 'wpsubdomain']: Log.debug(self, "Setting apt_packages variable for Nginx") + # Check if server has nginx-custom package if not EEAptGet.is_installed(self, 'nginx-custom'): - apt_packages = apt_packages + EEVariables.ee_nginx + # check if Server has nginx-plus installed + if EEAptGet.is_installed(self, 'nginx-plus'): + # do something + # do post nginx installation configuration + packages = [] + apt_packages = apt_packages + EEVariables.ee_nginx + stack.post_pref(apt_packages , packages) + + else: + apt_packages = apt_packages + EEVariables.ee_nginx else: # Fix for Nginx white screen death if not EEFileUtils.grep(self, '/etc/nginx/fastcgi_params', From fc347ffbdd01ab0c13114111cd0843aa76929214 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 13:30:58 +0530 Subject: [PATCH 02/10] setup nginx package as ee needs --- ee/cli/plugins/site_functions.py | 1 + ee/cli/plugins/stack.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index bd857691..03397542 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -661,6 +661,7 @@ def site_package_check(self, stype): if EEAptGet.is_installed(self, 'nginx-plus'): # do something # do post nginx installation configuration + apt_packages = ["nginx-plus"] packages = [] apt_packages = apt_packages + EEVariables.ee_nginx stack.post_pref(apt_packages , packages) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 59e42360..17533b03 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -329,6 +329,21 @@ class EEStackController(CementBaseController): out=ee_nginx) ee_nginx.close() + # Nginx-Plus does not have nginx package structure like this + # So craeting directories + if set(["nginx-plus"]).issubset(set(apt_packages)): + if not os.path.exists('/etc/nginx/sites-available'): + Log.debug(self, 'Creating directory' + '/etc/nginx/sites-available') + os.makedirs('/etc/nginx/sites-available') + + if not os.path.exists('/etc/nginx/sites-enabled'): + Log.debug(self, 'Creating directory' + '/etc/nginx/sites-available') + os.makedirs('/etc/nginx/sites-enabled') + + + # 22222 port settings Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/sites-available/' From afff3d423f40024062cada77df1b90c489d18e27 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 16:29:09 +0530 Subject: [PATCH 03/10] EasyEngine optimized configuration added --- ee/cli/plugins/site_functions.py | 7 +-- ee/cli/plugins/stack.py | 20 ++++++- ee/cli/templates/ee-plus.mustache | 86 +++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 ee/cli/templates/ee-plus.mustache diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 03397542..19e9543b 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -661,10 +661,11 @@ def site_package_check(self, stype): if EEAptGet.is_installed(self, 'nginx-plus'): # do something # do post nginx installation configuration - apt_packages = ["nginx-plus"] + print("NGINX-PLUS detected ...") + apt = ["nginx-plus"] + EEVariables.ee_nginx packages = [] - apt_packages = apt_packages + EEVariables.ee_nginx - stack.post_pref(apt_packages , packages) + #apt_packages = apt_packages + EEVariables.ee_nginx + stack.post_pref(apt, packages) else: apt_packages = apt_packages + EEVariables.ee_nginx diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 17533b03..0d6b3ec9 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -442,7 +442,25 @@ class EEStackController(CementBaseController): EEGit.add(self, ["/etc/nginx"], msg="Adding Nginx into Git") EEService.reload_service(self, 'nginx') - self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] + if set(["nginx-plus"]).issubset(set(apt_packages)): + EEShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'" + " -e '/^#user/a user" + "\ www-data\;'" + " /etc/nginx/nginx.conf") + + # EasyEngine config for NGINX plus + Log.debug(self, 'Writting for nginx plus configuration' + ' to file /etc/nginx/conf.d/ee-plus.conf') + ee_nginx = open('/etc/nginx/conf.d/ee-plus.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'ee-plus.mustache', + out=ee_nginx) + ee_nginx.close() + + print("HTTP Auth User Name: easyengine" + + "\nHTTP Auth Password : {0}".format(passwd)) + else: + self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] + ["HTTP Auth Password : {0}".format(passwd)]) if EEAptGet.is_installed(self,'redis-server'): diff --git a/ee/cli/templates/ee-plus.mustache b/ee/cli/templates/ee-plus.mustache new file mode 100644 index 00000000..3a2bf9de --- /dev/null +++ b/ee/cli/templates/ee-plus.mustache @@ -0,0 +1,86 @@ +## +# EasyEngine Settings +## + + +tcp_nopush on; +tcp_nodelay on; +types_hash_max_size 2048; + +server_tokens off; +reset_timedout_connection on; +add_header X-Powered-By "EasyEngine 3.3.5"; +add_header rt-Fastcgi-Cache $upstream_cache_status; + +# Limit Request +limit_req_status 403; +limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s; + +# Proxy Settings +# set_real_ip_from proxy-server-ip; +# real_ip_header X-Forwarded-For; + +fastcgi_read_timeout 300; +client_max_body_size 100m; + +## +# SSL Settings +## + +ssl_session_cache shared:SSL:20m; +ssl_session_timeout 10m; +ssl_prefer_server_ciphers on; +ssl_ciphers HIGH:!aNULL:!MD5:!kEDH; +ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + +## +# Basic Settings +## +server_names_hash_bucket_size 16384; +# server_name_in_redirect off; + + +## +# Logging Settings +## + +access_log /var/log/nginx/access.log; +error_log /var/log/nginx/error.log; + +# Log format Settings +log_format rt_cache '$remote_addr $upstream_response_time $upstream_cache_status [$time_local] ' +'$http_host "$request" $status $body_bytes_sent ' +'"$http_referer" "$http_user_agent" "$request_body"'; + +## +# Gzip Settings +## + +gzip on; +gzip_disable "msie6"; + +gzip_vary on; +gzip_proxied any; +gzip_comp_level 6; +gzip_buffers 16 8k; +gzip_http_version 1.1; +gzip_types + application/atom+xml + application/javascript + application/json + application/rss+xml + application/vnd.ms-fontobject + application/x-font-ttf + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/opentype + image/svg+xml + image/x-icon + text/css + text/plain + text/x-component + text/xml + text/javascript; + +include /etc/nginx/sites-enabled/*; From 8c1f5ac942de7054797504d08ef375e7232e3b86 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 16:38:53 +0530 Subject: [PATCH 04/10] add EasyEngine version dynamically --- ee/cli/plugins/stack.py | 1 + ee/cli/templates/ee-plus.mustache | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 0d6b3ec9..d6cd6707 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -449,6 +449,7 @@ class EEStackController(CementBaseController): " /etc/nginx/nginx.conf") # EasyEngine config for NGINX plus + data['version'] = EEVariables.ee_version Log.debug(self, 'Writting for nginx plus configuration' ' to file /etc/nginx/conf.d/ee-plus.conf') ee_nginx = open('/etc/nginx/conf.d/ee-plus.conf', diff --git a/ee/cli/templates/ee-plus.mustache b/ee/cli/templates/ee-plus.mustache index 3a2bf9de..61a0e0a5 100644 --- a/ee/cli/templates/ee-plus.mustache +++ b/ee/cli/templates/ee-plus.mustache @@ -9,7 +9,7 @@ types_hash_max_size 2048; server_tokens off; reset_timedout_connection on; -add_header X-Powered-By "EasyEngine 3.3.5"; +add_header X-Powered-By "EasyEngine {{ version }}"; add_header rt-Fastcgi-Cache $upstream_cache_status; # Limit Request From 22f547d4d702535075a4b8dc7d37cfd00427be0a Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 17:04:38 +0530 Subject: [PATCH 05/10] do not install nginx-custom if nginx-plus installed --- ee/cli/plugins/site_functions.py | 5 +++-- ee/cli/plugins/stack.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 19e9543b..04d99909 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -661,9 +661,10 @@ def site_package_check(self, stype): if EEAptGet.is_installed(self, 'nginx-plus'): # do something # do post nginx installation configuration - print("NGINX-PLUS detected ...") + Log.info(self, "NGINX PLUS Detected ...") + Log.info(self, + "Installing EasyEngine Configurations for NGINX PLUS") apt = ["nginx-plus"] + EEVariables.ee_nginx - packages = [] #apt_packages = apt_packages + EEVariables.ee_nginx stack.post_pref(apt, packages) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index d6cd6707..211ea8bd 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -449,7 +449,7 @@ class EEStackController(CementBaseController): " /etc/nginx/nginx.conf") # EasyEngine config for NGINX plus - data['version'] = EEVariables.ee_version + data['version'] = EEVariables.ee_version Log.debug(self, 'Writting for nginx plus configuration' ' to file /etc/nginx/conf.d/ee-plus.conf') ee_nginx = open('/etc/nginx/conf.d/ee-plus.conf', @@ -1605,7 +1605,15 @@ class EEStackController(CementBaseController): Log.debug(self, "Setting apt_packages variable for Nginx") if not EEAptGet.is_installed(self, 'nginx-custom'): - apt_packages = apt_packages + EEVariables.ee_nginx + if not EEAptGet.is_installed(self, 'nginx-plus'): + apt_packages = apt_packages + EEVariables.ee_nginx + else: + Log.info(self, "NGINX PLUS Detected ...") + Log.info(self, + "Installing EasyEngine Configurations for NGINX PLUS") + apt = ["nginx-plus"] + EEVariables.ee_nginx + #apt_packages = apt_packages + EEVariables.ee_nginx + self.post_pref(apt, packages) else: Log.debug(self, "Nginx already installed") Log.info(self, "Nginx already installed") From 16c555f0bb219c03c8d84689e3cdbbe91d774ecc Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 17:15:35 +0530 Subject: [PATCH 06/10] update message --- ee/cli/plugins/stack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 211ea8bd..b71dd459 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -332,6 +332,8 @@ class EEStackController(CementBaseController): # Nginx-Plus does not have nginx package structure like this # So craeting directories if set(["nginx-plus"]).issubset(set(apt_packages)): + Log.info(self, + "Installing EasyEngine Configurations for" "NGINX PLUS") if not os.path.exists('/etc/nginx/sites-available'): Log.debug(self, 'Creating directory' '/etc/nginx/sites-available') @@ -1609,8 +1611,6 @@ class EEStackController(CementBaseController): apt_packages = apt_packages + EEVariables.ee_nginx else: Log.info(self, "NGINX PLUS Detected ...") - Log.info(self, - "Installing EasyEngine Configurations for NGINX PLUS") apt = ["nginx-plus"] + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx self.post_pref(apt, packages) From 240d66eefdb13583d3723e32938ab84ce3fb7421 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 18:10:21 +0530 Subject: [PATCH 07/10] fixed zone WORDPRESS conflicts --- ee/cli/plugins/stack.py | 8 ++++++++ ee/cli/templates/ee-plus.mustache | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index b71dd459..811081e8 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -449,6 +449,14 @@ class EEStackController(CementBaseController): " -e '/^#user/a user" "\ www-data\;'" " /etc/nginx/nginx.conf") + if not EEShellExec.cmd_exec(self, "cat /etc/nginx/" + "nginx.conf | grep -q " + "'/etc/nginx/sites-enabled'"): + EEShellExec.cmd_exec(self, "sed -i '/\/etc\/" + "nginx\/conf\.d\/\*" + "\.conf/a \ include" + "\ \/etc\/nginx\/sites-enabled" + "\/*;' /etc/nginx/nginx.conf") # EasyEngine config for NGINX plus data['version'] = EEVariables.ee_version diff --git a/ee/cli/templates/ee-plus.mustache b/ee/cli/templates/ee-plus.mustache index 61a0e0a5..fc90602b 100644 --- a/ee/cli/templates/ee-plus.mustache +++ b/ee/cli/templates/ee-plus.mustache @@ -82,5 +82,3 @@ gzip_types text/x-component text/xml text/javascript; - -include /etc/nginx/sites-enabled/*; From 5b006de0174b8421d64ccc77b0d1e26c5b71e4e6 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 18:16:29 +0530 Subject: [PATCH 08/10] remove unwanted message --- ee/cli/plugins/site_functions.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ee/cli/plugins/site_functions.py b/ee/cli/plugins/site_functions.py index 04d99909..28a310f6 100644 --- a/ee/cli/plugins/site_functions.py +++ b/ee/cli/plugins/site_functions.py @@ -662,8 +662,6 @@ def site_package_check(self, stype): # do something # do post nginx installation configuration Log.info(self, "NGINX PLUS Detected ...") - Log.info(self, - "Installing EasyEngine Configurations for NGINX PLUS") apt = ["nginx-plus"] + EEVariables.ee_nginx #apt_packages = apt_packages + EEVariables.ee_nginx stack.post_pref(apt, packages) From 5f4398b66e37b00810caf3397fcc439d03b3be11 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 21:17:14 +0530 Subject: [PATCH 09/10] reload nginx --- ee/cli/plugins/stack.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ee/cli/plugins/stack.py b/ee/cli/plugins/stack.py index 811081e8..0681148e 100644 --- a/ee/cli/plugins/stack.py +++ b/ee/cli/plugins/stack.py @@ -470,6 +470,7 @@ class EEStackController(CementBaseController): print("HTTP Auth User Name: easyengine" + "\nHTTP Auth Password : {0}".format(passwd)) + EEService.reload_service(self, 'nginx') else: self.msg = (self.msg + ["HTTP Auth User Name: easyengine"] + ["HTTP Auth Password : {0}".format(passwd)]) From 7e1393e39a09ad5d12a14f44c8b378b587f4b804 Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Wed, 9 Sep 2015 21:47:19 +0530 Subject: [PATCH 10/10] version updated --- CHANGELOG.txt | 3 +++ docs/ee.8 | 2 +- ee/core/variables.py | 2 +- install | 2 +- setup.py | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b323cb8d..0a6d1c86 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +v 3.3.7 - Sep 9, 2015 +- EasyEngine + NGINX PLUS (http://docs.rtcamp.com/easyengine/nginx-plus/) + v 3.3.6 - Sep 4, 2015 - Fix #611 diff --git a/docs/ee.8 b/docs/ee.8 index 86708e12..d28c45d8 100644 --- a/docs/ee.8 +++ b/docs/ee.8 @@ -1,4 +1,4 @@ -.TH ee 8 "EasyEngine (ee) version: 3.3.6" "Sept 4,2015" "EasyEngine" +.TH ee 8 "EasyEngine (ee) version: 3.3.7" "Sep 9,2015" "EasyEngine" .SH NAME .B EasyEngine (ee) \- Manage Nginx Based Websites. diff --git a/ee/core/variables.py b/ee/core/variables.py index 709d901f..7517fbc5 100644 --- a/ee/core/variables.py +++ b/ee/core/variables.py @@ -12,7 +12,7 @@ class EEVariables(): """Intialization of core variables""" # EasyEngine version - ee_version = "3.3.6" + ee_version = "3.3.7" # EasyEngine packages versions diff --git a/install b/install index bd933382..ca9cd95a 100644 --- a/install +++ b/install @@ -48,7 +48,7 @@ fi # Define variables for later use ee_branch=$1 readonly ee_version_old="2.2.3" -readonly ee_version_new="3.3.6" +readonly ee_version_new="3.3.7" readonly ee_log_dir=/var/log/ee/ readonly ee_install_log=/var/log/ee/install.log readonly ee_linux_distro=$(lsb_release -i | awk '{print $3}') diff --git a/setup.py b/setup.py index 23746fd0..56d803af 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ except Exception as e: os.system("git config --global user.email {0}".format(ee_email)) setup(name='ee', - version='3.3.6', + version='3.3.7', description=long_description, long_description=long_description, classifiers=[],