From a2e6f0279572a936e5a402ef7bf76316679eea3d Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Wed, 27 Mar 2019 04:58:25 +0100 Subject: [PATCH] simplify locations nginx template --- install | 2 +- wo/cli/plugins/stack.py | 28 +++++++++------------- wo/cli/templates/22222.mustache | 6 ++--- wo/cli/templates/fastcgi.mustache | 2 +- wo/cli/templates/locations-php7.mustache | 28 +--------------------- wo/cli/templates/locations.mustache | 28 +--------------------- wo/cli/templates/map-wp.mustache | 3 +-- wo/cli/templates/php.mustache | 2 +- wo/cli/templates/php7.mustache | 2 +- wo/cli/templates/redis-php7.mustache | 2 +- wo/cli/templates/redis.mustache | 2 +- wo/cli/templates/upstream.mustache | 2 +- wo/cli/templates/virtualconf-php7.mustache | 6 ++--- wo/cli/templates/virtualconf.mustache | 10 ++++---- wo/cli/templates/webp.mustache | 2 +- wo/cli/templates/wpcommon-php7.mustache | 2 +- wo/cli/templates/wpcommon.mustache | 2 +- wo/cli/templates/wpfc-php7.mustache | 2 +- wo/cli/templates/wpfc.mustache | 2 +- wo/cli/templates/wpsc-php7.mustache | 2 +- wo/cli/templates/wpsc.mustache | 2 +- 21 files changed, 39 insertions(+), 98 deletions(-) diff --git a/install b/install index 82e6c5a..ef6d4e6 100644 --- a/install +++ b/install @@ -425,7 +425,7 @@ wo_upgrade_nginx() { rm -f /tmp/nginx-wo.key sudo apt-get update - CHECK_NGINX_UPSTREAM_VERSION=$(grep "v3.9.5" /etc/nginx/conf.d/upstream.conf) + CHECK_NGINX_UPSTREAM_VERSION=$(grep "v3.9.5" /etc/nginx/conf.d/fastcgi.conf) if [ -z "$CHECK_NGINX_UPSTREAM_VERSION" ]; then # stop nginx diff --git a/wo/cli/plugins/stack.py b/wo/cli/plugins/stack.py index d3bef64..41974b0 100644 --- a/wo/cli/plugins/stack.py +++ b/wo/cli/plugins/stack.py @@ -271,8 +271,8 @@ class WOStackController(CementBaseController): wo_nginx.close() Log.debug(self, 'Writting the nginx configuration to ' - 'file /etc/nginx/common/locations-php72.conf') - wo_nginx = open('/etc/nginx/common/locations-php72.conf', + 'file /etc/nginx/common/locations-wo.conf') + wo_nginx = open('/etc/nginx/common/locations-wo.conf', encoding='utf-8', mode='w') self.app.render((data), 'locations.mustache', out=wo_nginx) @@ -321,14 +321,6 @@ class WOStackController(CementBaseController): # php73 conf if not os.path.isfile("/etc/nginx/common/php73.conf"): # data = dict() - Log.debug(self, 'Writting the nginx configuration to ' - 'file /etc/nginx/common/locations-php73.conf') - wo_nginx = open('/etc/nginx/common/locations-php73.conf', - encoding='utf-8', mode='w') - self.app.render((data), 'locations-php7.mustache', - out=wo_nginx) - wo_nginx.close() - Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/php73.conf') wo_nginx = open('/etc/nginx/common/php73.conf', @@ -369,6 +361,15 @@ class WOStackController(CementBaseController): out=wo_nginx) wo_nginx.close() + if not os.path.isfile("/etc/nginx/common/locations-wo.conf"): + Log.debug(self, 'Writting the nginx configuration to ' + 'file /etc/nginx/common/locations-wo.conf') + wo_nginx = open('/etc/nginx/common/locations-wo.conf', + encoding='utf-8', mode='w') + self.app.render((data), 'locations.mustache', + out=wo_nginx) + wo_nginx.close() + # Nginx-Plus does not have nginx # package structure like this # So creating directories @@ -564,13 +565,6 @@ class WOStackController(CementBaseController): if (os.path.isdir("/etc/nginx/common") and not os.path.isfile("/etc/nginx/common/php73.conf")): data = dict() - Log.debug(self, 'Writting the nginx configuration to ' - 'file /etc/nginx/common/locations-php73.conf') - wo_nginx = open('/etc/nginx/common/locations-php73.conf', - encoding='utf-8', mode='w') - self.app.render((data), 'locations-php7.mustache', - out=wo_nginx) - wo_nginx.close() Log.debug(self, 'Writting the nginx configuration to ' 'file /etc/nginx/common/php73.conf') diff --git a/wo/cli/templates/22222.mustache b/wo/cli/templates/22222.mustache index 232e88f..82bfcb6 100644 --- a/wo/cli/templates/22222.mustache +++ b/wo/cli/templates/22222.mustache @@ -1,4 +1,4 @@ -# WordOps admin NGINX CONFIGURATION +# WordOps admin NGINX CONFIGURATION - WO v3.9.5 server { @@ -21,7 +21,7 @@ server { # HTTP Authentication on port 22222 include common/acl.conf; - + # nginx-vts-status location /vts_status { vhost_traffic_status_display; @@ -47,7 +47,7 @@ server { include fastcgi_params; fastcgi_pass php72; } - + location /netdata { return 301 /netdata/; } diff --git a/wo/cli/templates/fastcgi.mustache b/wo/cli/templates/fastcgi.mustache index fcf02bd..be7469a 100644 --- a/wo/cli/templates/fastcgi.mustache +++ b/wo/cli/templates/fastcgi.mustache @@ -1,4 +1,4 @@ -# FastCGI cache settings +# FastCGI cache settings - WO v3.9.5 fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:50m inactive=60m max_size=256M; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header updating http_500 http_503; diff --git a/wo/cli/templates/locations-php7.mustache b/wo/cli/templates/locations-php7.mustache index 9576ff3..267891c 100644 --- a/wo/cli/templates/locations-php7.mustache +++ b/wo/cli/templates/locations-php7.mustache @@ -1,4 +1,4 @@ -# NGINX CONFIGURATION FOR COMMON LOCATION +# NGINX CONFIGURATION FOR COMMON LOCATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # Basic locations files location = /favicon.ico { @@ -52,29 +52,3 @@ location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|b location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { deny all; } -# Status pages -location = /nginx_status { - stub_status on; - access_log off; - include common/acl.conf; -} -location ~ ^/(status|ping)$ { - include fastcgi_params; - fastcgi_pass php73; - include common/acl.conf; -} -# WordOps (wo) utilities -# phpMyAdmin settings -location = /pma { - return 301 https://$host:22222/db/pma; -} -location = /phpMyAdmin { - return 301 https://$host:22222/db/pma; -} -location = /phpmyadmin { - return 301 https://$host:22222/db/pma; -} -# Adminer settings -location = /adminer { - return 301 https://$host:22222/db/adminer; -} diff --git a/wo/cli/templates/locations.mustache b/wo/cli/templates/locations.mustache index 88c98b4..267891c 100644 --- a/wo/cli/templates/locations.mustache +++ b/wo/cli/templates/locations.mustache @@ -1,4 +1,4 @@ -# NGINX CONFIGURATION FOR COMMON LOCATION +# NGINX CONFIGURATION FOR COMMON LOCATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # Basic locations files location = /favicon.ico { @@ -52,29 +52,3 @@ location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|b location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" { deny all; } -# Status pages -location = /nginx_status { - stub_status on; - access_log off; - include common/acl.conf; -} -location ~ ^/(status|ping)$ { - include fastcgi_params; - fastcgi_pass php72; - include common/acl.conf; -} -# WordOps (wo) utilities -# phpMyAdmin settings -location = /pma { - return 301 https://$host:22222/db/pma; -} -location = /phpMyAdmin { - return 301 https://$host:22222/db/pma; -} -location = /phpmyadmin { - return 301 https://$host:22222/db/pma; -} -# Adminer settings -location = /adminer { - return 301 https://$host:22222/db/adminer; -} diff --git a/wo/cli/templates/map-wp.mustache b/wo/cli/templates/map-wp.mustache index cd6b21e..a289cee 100644 --- a/wo/cli/templates/map-wp.mustache +++ b/wo/cli/templates/map-wp.mustache @@ -1,4 +1,4 @@ -# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION +# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # do not cache xhtml request @@ -52,4 +52,3 @@ map $skip_cache $cache_uri { default 'null cache'; 0 $request_uri; } - diff --git a/wo/cli/templates/php.mustache b/wo/cli/templates/php.mustache index 7288f48..59903a8 100644 --- a/wo/cli/templates/php.mustache +++ b/wo/cli/templates/php.mustache @@ -1,4 +1,4 @@ -# PHP NGINX CONFIGURATION +# PHP NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE location / { try_files $uri $uri/ /index.php$is_args$args; diff --git a/wo/cli/templates/php7.mustache b/wo/cli/templates/php7.mustache index d0ab167..4005572 100644 --- a/wo/cli/templates/php7.mustache +++ b/wo/cli/templates/php7.mustache @@ -1,4 +1,4 @@ -# PHP NGINX CONFIGURATION +# PHP NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE location / { try_files $uri $uri/ /index.php$is_args$args; diff --git a/wo/cli/templates/redis-php7.mustache b/wo/cli/templates/redis-php7.mustache index 217509d..5e21f7a 100644 --- a/wo/cli/templates/redis-php7.mustache +++ b/wo/cli/templates/redis-php7.mustache @@ -1,4 +1,4 @@ -# Redis NGINX CONFIGURATION +# Redis NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf diff --git a/wo/cli/templates/redis.mustache b/wo/cli/templates/redis.mustache index 0a7004f..cdde0b1 100644 --- a/wo/cli/templates/redis.mustache +++ b/wo/cli/templates/redis.mustache @@ -1,4 +1,4 @@ -# Redis NGINX CONFIGURATION +# Redis NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf diff --git a/wo/cli/templates/upstream.mustache b/wo/cli/templates/upstream.mustache index fe3aa45..26e06b9 100644 --- a/wo/cli/templates/upstream.mustache +++ b/wo/cli/templates/upstream.mustache @@ -1,4 +1,4 @@ -# NGINX UPSTREAM CONFIGURATION v3.9.5 +# NGINX UPSTREAM CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE #------------------------------- # PHP 5.6 diff --git a/wo/cli/templates/virtualconf-php7.mustache b/wo/cli/templates/virtualconf-php7.mustache index c06e1e7..625fd2a 100644 --- a/wo/cli/templates/virtualconf-php7.mustache +++ b/wo/cli/templates/virtualconf-php7.mustache @@ -25,7 +25,7 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - + # Security settings for better privacy # Deny hidden files location ~ /\.(?!well-known\/) { @@ -52,7 +52,7 @@ server { {{^static}}include {{#basic}}common/php73.conf;{{/basic}}{{#wpfc}}common/wpfc-php73.conf;{{/wpfc}} {{#wpsc}}common/wpsc-php73.conf;{{/wpsc}}{{#wpredis}}common/redis-php73.conf;{{/wpredis}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wp}}include common/wpcommon-php73.conf;{{/wp}} - include common/locations-php73.conf;{{/proxy}} + include common/locations-wo.conf;{{/proxy}} include {{webroot}}/conf/nginx/*.conf; - + } diff --git a/wo/cli/templates/virtualconf.mustache b/wo/cli/templates/virtualconf.mustache index 5aea885..d8610de 100644 --- a/wo/cli/templates/virtualconf.mustache +++ b/wo/cli/templates/virtualconf.mustache @@ -13,7 +13,7 @@ server { #server_name_in_redirect off; {{/multisite}} - access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}}; + access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}}; error_log /var/log/nginx/{{site_name}}.error.log; {{#proxy}} @@ -25,7 +25,7 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - + # Security settings for better privacy # Deny hidden files location ~ /\.(?!well-known\/) { @@ -40,7 +40,7 @@ server { {{^proxy}} root {{webroot}}/htdocs; - + index {{^static}}index.php{{/static}} index.html index.htm; {{#static}} @@ -52,7 +52,7 @@ server { {{^static}}include {{#basic}}common/php72.conf;{{/basic}}{{#wpfc}}common/wpfc-php72.conf;{{/wpfc}} {{#wpsc}}common/wpsc-php72.conf;{{/wpsc}}{{#wpredis}}common/redis-php72.conf;{{/wpredis}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wp}}include common/wpcommon-php72.conf;{{/wp}} - include common/locations-php72.conf;{{/proxy}} + include common/locations-wo.conf;{{/proxy}} include {{webroot}}/conf/nginx/*.conf; - + } diff --git a/wo/cli/templates/webp.mustache b/wo/cli/templates/webp.mustache index db3aac4..3ed187b 100644 --- a/wo/cli/templates/webp.mustache +++ b/wo/cli/templates/webp.mustache @@ -1,4 +1,4 @@ -# WEBP NGINX CONFIGURATION +# WEBP NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE map $http_accept $webp_suffix { diff --git a/wo/cli/templates/wpcommon-php7.mustache b/wo/cli/templates/wpcommon-php7.mustache index e99977b..52054ad 100644 --- a/wo/cli/templates/wpcommon-php7.mustache +++ b/wo/cli/templates/wpcommon-php7.mustache @@ -1,4 +1,4 @@ -# WordPress COMMON SETTINGS +# WordPress COMMON SETTINGS - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # Limit access to avoid brute force attack location = /wp-login.php { diff --git a/wo/cli/templates/wpcommon.mustache b/wo/cli/templates/wpcommon.mustache index 89f0e92..8ddc377 100644 --- a/wo/cli/templates/wpcommon.mustache +++ b/wo/cli/templates/wpcommon.mustache @@ -1,4 +1,4 @@ -# WordPress COMMON SETTINGS +# WordPress COMMON SETTINGS - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # Limit access to avoid brute force attack location = /wp-login.php { diff --git a/wo/cli/templates/wpfc-php7.mustache b/wo/cli/templates/wpfc-php7.mustache index aa7f087..3667c40 100644 --- a/wo/cli/templates/wpfc-php7.mustache +++ b/wo/cli/templates/wpfc-php7.mustache @@ -1,4 +1,4 @@ -# WPFC NGINX CONFIGURATION +# WPFC NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf diff --git a/wo/cli/templates/wpfc.mustache b/wo/cli/templates/wpfc.mustache index 12258d8..447870f 100644 --- a/wo/cli/templates/wpfc.mustache +++ b/wo/cli/templates/wpfc.mustache @@ -1,4 +1,4 @@ -# WPFC NGINX CONFIGURATION +# WPFC NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf diff --git a/wo/cli/templates/wpsc-php7.mustache b/wo/cli/templates/wpsc-php7.mustache index 9c5267e..1fe48a6 100644 --- a/wo/cli/templates/wpsc-php7.mustache +++ b/wo/cli/templates/wpsc-php7.mustache @@ -1,4 +1,4 @@ -# WPSC NGINX CONFIGURATION +# WPSC NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $cache_uri variable set in /etc/nginx/conf.d/map-wp.conf diff --git a/wo/cli/templates/wpsc.mustache b/wo/cli/templates/wpsc.mustache index d1f795c..cfe5070 100644 --- a/wo/cli/templates/wpsc.mustache +++ b/wo/cli/templates/wpsc.mustache @@ -1,4 +1,4 @@ -# WPSC NGINX CONFIGURATION +# WPSC NGINX CONFIGURATION - WO v3.9.5 # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # $cache_uri variable set in /etc/nginx/conf.d/map-wp.conf