Implement --wprocket

* cleanup templates by using variables
* add configuration for wp-rocket
* update mapping for wp-rocket
This commit is contained in:
VirtuBox
2019-08-05 19:17:59 +02:00
parent fc52635c95
commit 304a31b8e8
22 changed files with 131 additions and 259 deletions

View File

@@ -333,6 +333,9 @@ class WOSiteCreateController(CementBaseController):
(['--wpsc'], (['--wpsc'],
dict(help="create WordPress single/multi site with wpsc cache", dict(help="create WordPress single/multi site with wpsc cache",
action='store_true')), action='store_true')),
(['--wprocket'],
dict(help="create WordPress single/multi site with WP-Rocket",
action='store_true')),
(['--wpredis'], (['--wpredis'],
dict(help="create WordPress single/multi site " dict(help="create WordPress single/multi site "
"with redis cache", "with redis cache",
@@ -423,7 +426,8 @@ class WOSiteCreateController(CementBaseController):
if stype == 'proxy': if stype == 'proxy':
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=True, basic=False, php73=False, wp=False, static=True, basic=False, php73=False, wp=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wprocket=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot) wpsubdir=False, webroot=wo_site_webroot)
data['proxy'] = True data['proxy'] = True
data['host'] = host data['host'] = host
@@ -433,14 +437,16 @@ class WOSiteCreateController(CementBaseController):
if self.app.pargs.php73: if self.app.pargs.php73:
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=False, php73=True, wp=False, static=False, basic=False, php73=True, wp=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wprocket=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot) wpsubdir=False, webroot=wo_site_webroot)
data['basic'] = True data['basic'] = True
if stype in ['html', 'php']: if stype in ['html', 'php']:
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=True, basic=False, php73=False, wp=False, static=True, basic=False, php73=False, wp=False,
wpfc=False, wpsc=False, multisite=False, wpfc=False, wpsc=False, wprocket=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot) wpsubdir=False, webroot=wo_site_webroot)
if stype == 'php': if stype == 'php':
@@ -451,7 +457,8 @@ class WOSiteCreateController(CementBaseController):
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False, static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, multisite=False, wpsc=False, wpredis=False, wprocket=False,
multisite=False,
wpsubdir=False, webroot=wo_site_webroot, wpsubdir=False, webroot=wo_site_webroot,
wo_db_name='', wo_db_user='', wo_db_pass='', wo_db_name='', wo_db_user='', wo_db_pass='',
wo_db_host='') wo_db_host='')
@@ -479,6 +486,7 @@ class WOSiteCreateController(CementBaseController):
if ((not self.app.pargs.wpfc) and if ((not self.app.pargs.wpfc) and
(not self.app.pargs.wpsc) and (not self.app.pargs.wpsc) and
(not self.app.pargs.wprocket) and
(not self.app.pargs.wpredis)): (not self.app.pargs.wpredis)):
data['basic'] = True data['basic'] = True
@@ -488,6 +496,7 @@ class WOSiteCreateController(CementBaseController):
data['basic'] = False data['basic'] = False
self.app.pargs.wpredis = True self.app.pargs.wpredis = True
# Check rerequired packages are installed or not # Check rerequired packages are installed or not
wo_auth = site_package_check(self, stype) wo_auth = site_package_check(self, stype)
@@ -825,6 +834,8 @@ class WOSiteUpdateController(CementBaseController):
dict(help="update to wpfc cache", action='store_true')), dict(help="update to wpfc cache", action='store_true')),
(['--wpsc'], (['--wpsc'],
dict(help="update to wpsc cache", action='store_true')), dict(help="update to wpsc cache", action='store_true')),
(['--wprocket'],
dict(help="update to WP-Rocket cache", action='store_true')),
(['--wpredis'], (['--wpredis'],
dict(help="update to redis cache", action='store_true')), dict(help="update to redis cache", action='store_true')),
(['-le', '--letsencrypt'], (['-le', '--letsencrypt'],
@@ -868,6 +879,7 @@ class WOSiteUpdateController(CementBaseController):
if not (pargs.php or pargs.php73 or if not (pargs.php or pargs.php73 or
pargs.mysql or pargs.wp or pargs.wpsubdir or pargs.mysql or pargs.wp or pargs.wpsubdir or
pargs.wpsubdomain or pargs.wpfc or pargs.wpsc or pargs.wpsubdomain or pargs.wpfc or pargs.wpsc or
pargs.wprocket or
pargs.wpredis or pargs.letsencrypt or pargs.hsts or pargs.wpredis or pargs.letsencrypt or pargs.hsts or
pargs.dns or pargs.force): pargs.dns or pargs.force):
Log.error(self, "Please provide options to update sites.") Log.error(self, "Please provide options to update sites.")
@@ -946,6 +958,7 @@ class WOSiteUpdateController(CementBaseController):
if (pargs.password and not (pargs.html or if (pargs.password and not (pargs.html or
pargs.php or pargs.php73 or pargs.mysql or pargs.php or pargs.php73 or pargs.mysql or
pargs.wp or pargs.wpfc or pargs.wpsc or pargs.wp or pargs.wpfc or pargs.wpsc or
pargs.wprocket or
pargs.wpsubdir or pargs.wpsubdomain or pargs.wpsubdir or pargs.wpsubdomain or
pargs.hsts)): pargs.hsts)):
try: try:
@@ -958,6 +971,7 @@ class WOSiteUpdateController(CementBaseController):
if (pargs.hsts and not (pargs.html or if (pargs.hsts and not (pargs.html or
pargs.php or pargs.php73 or pargs.mysql or pargs.php or pargs.php73 or pargs.mysql or
pargs.wp or pargs.wpfc or pargs.wpsc or pargs.wp or pargs.wpfc or pargs.wpsc or
pargs.wprocket or
pargs.wpsubdir or pargs.wpsubdomain or pargs.wpsubdir or pargs.wpsubdomain or
pargs.password)): pargs.password)):
try: try:
@@ -999,7 +1013,7 @@ class WOSiteUpdateController(CementBaseController):
if stype == 'php': if stype == 'php':
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False, static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, multisite=False, wpsc=False, wpredis=False, wprocket=False, multisite=False,
wpsubdir=False, webroot=wo_site_webroot, wpsubdir=False, webroot=wo_site_webroot,
currsitetype=oldsitetype, currcachetype=oldcachetype) currsitetype=oldsitetype, currcachetype=oldcachetype)
@@ -1007,7 +1021,7 @@ class WOSiteUpdateController(CementBaseController):
data = dict(site_name=wo_domain, www_domain=wo_www_domain, data = dict(site_name=wo_domain, www_domain=wo_www_domain,
static=False, basic=True, wp=False, wpfc=False, static=False, basic=True, wp=False, wpfc=False,
wpsc=False, wpredis=False, multisite=False, wpsc=False, wpredis=False, wprocket=False, multisite=False,
wpsubdir=False, webroot=wo_site_webroot, wpsubdir=False, webroot=wo_site_webroot,
wo_db_name='', wo_db_user='', wo_db_pass='', wo_db_name='', wo_db_user='', wo_db_pass='',
wo_db_host='', wo_db_host='',
@@ -1061,21 +1075,31 @@ class WOSiteUpdateController(CementBaseController):
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = False data['wpredis'] = False
data['wprocket'] = False
elif oldcachetype == 'wpfc': elif oldcachetype == 'wpfc':
data['basic'] = False data['basic'] = False
data['wpfc'] = True data['wpfc'] = True
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = False data['wpredis'] = False
data['wprocket'] = False
elif oldcachetype == 'wpsc': elif oldcachetype == 'wpsc':
data['basic'] = False data['basic'] = False
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = True data['wpsc'] = True
data['wpredis'] = False data['wpredis'] = False
data['wprocket'] = False
elif oldcachetype == 'wpredis': elif oldcachetype == 'wpredis':
data['basic'] = False data['basic'] = False
data['wpfc'] = False data['wpfc'] = False
data['wpsc'] = False data['wpsc'] = False
data['wpredis'] = True data['wpredis'] = True
data['wprocket'] = False
elif oldcachetype == 'wprocket':
data['basic'] = False
data['wpfc'] = False
data['wpsc'] = False
data['wpredis'] = False
data['wprocket'] = True
if pargs.php73 == 'on': if pargs.php73 == 'on':
data['php73'] = True data['php73'] = True
@@ -1233,6 +1257,11 @@ class WOSiteUpdateController(CementBaseController):
data['basic'] = False data['basic'] = False
cache = 'wpredis' cache = 'wpredis'
if pargs.wprocket and data['currcachetype'] != 'wprocket':
data['wprocket'] = True
data['basic'] = False
cache = 'wprocket'
if (php73 is old_php73) and (stype == oldsitetype and if (php73 is old_php73) and (stype == oldsitetype and
cache == oldcachetype): cache == oldcachetype):
return 1 return 1
@@ -1620,6 +1649,16 @@ class WOSiteUpdateController(CementBaseController):
"`tail /var/log/wo/wordops.log` and please try again") "`tail /var/log/wo/wordops.log` and please try again")
return 1 return 1
if oldcachetype == 'wprocket' and not data['wprocket']:
try:
uninstallwp_plugin(self, 'wp-rocket', data)
except SiteError as e:
Log.debug(self, str(e))
Log.info(self, Log.FAIL + "Update site failed."
"Check the log for details: "
"`tail /var/log/wo/wordops.log` and please try again")
return 1
# Service Nginx Reload # Service Nginx Reload
if not WOService.reload_service(self, 'nginx'): if not WOService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "

View File

@@ -897,12 +897,12 @@ def site_package_check(self, stype):
if (os.path.isdir("/etc/nginx/common") and if (os.path.isdir("/etc/nginx/common") and
not os.path.isfile("/etc/nginx/common/locations-wo.conf")): not os.path.isfile("/etc/nginx/common/locations-wo.conf")):
data = dict() data = dict(upstream="php73")
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/locations-wo.conf') 'file /etc/nginx/common/locations-wo.conf')
wo_nginx = open('/etc/nginx/common/locations-wo.conf', wo_nginx = open('/etc/nginx/common/locations-wo.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'locations-php7.mustache', self.app.render((data), 'locations.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -910,7 +910,7 @@ def site_package_check(self, stype):
'file /etc/nginx/common/php73.conf') 'file /etc/nginx/common/php73.conf')
wo_nginx = open('/etc/nginx/common/php73.conf', wo_nginx = open('/etc/nginx/common/php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'php7.mustache', self.app.render((data), 'php.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -918,7 +918,7 @@ def site_package_check(self, stype):
'file /etc/nginx/common/wpcommon-php73.conf') 'file /etc/nginx/common/wpcommon-php73.conf')
wo_nginx = open('/etc/nginx/common/wpcommon-php73.conf', wo_nginx = open('/etc/nginx/common/wpcommon-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon-php7.mustache', self.app.render((data), 'wpcommon.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -926,7 +926,7 @@ def site_package_check(self, stype):
'file /etc/nginx/common/wpfc-php73.conf') 'file /etc/nginx/common/wpfc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpfc-php73.conf', wo_nginx = open('/etc/nginx/common/wpfc-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-php7.mustache', self.app.render((data), 'wpfc.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -934,18 +934,26 @@ def site_package_check(self, stype):
'file /etc/nginx/common/wpsc-php73.conf') 'file /etc/nginx/common/wpsc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpsc-php73.conf', wo_nginx = open('/etc/nginx/common/wpsc-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-php7.mustache', self.app.render((data), 'wpsc.mustache',
out=wo_nginx)
wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wprocket-php73.conf')
wo_nginx = open('/etc/nginx/common/wprocket-php73.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wprocket.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
if (os.path.isfile("/etc/nginx/nginx.conf") and if (os.path.isfile("/etc/nginx/nginx.conf") and
not os.path.isfile("/etc/nginx/common/redis-php73.conf")): not os.path.isfile("/etc/nginx/common/redis-php73.conf")):
data = dict() data = dict(upstream="php73")
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php73.conf') 'file /etc/nginx/common/redis-php73.conf')
wo_nginx = open('/etc/nginx/common/redis-php73.conf', wo_nginx = open('/etc/nginx/common/redis-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache', self.app.render((data), 'redis.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()

View File

@@ -230,7 +230,7 @@ def post_pref(self, apt_packages, packages):
os.makedirs('/etc/nginx/common') os.makedirs('/etc/nginx/common')
if os.path.exists('/etc/nginx/common'): if os.path.exists('/etc/nginx/common'):
data = dict(webroot=WOVariables.wo_webroot) data = dict()
# Common Configuration # Common Configuration
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
@@ -248,7 +248,7 @@ def post_pref(self, apt_packages, packages):
self.app.render((data), 'wpsubdir.mustache', self.app.render((data), 'wpsubdir.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
data = dict(upstream="php72")
# PHP 7.2 conf # PHP 7.2 conf
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php72.conf') 'file /etc/nginx/common/php72.conf')
@@ -258,6 +258,14 @@ def post_pref(self, apt_packages, packages):
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php72.conf')
wo_nginx = open('/etc/nginx/common/redis-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache',
out=wo_nginx)
wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wpcommon-php72.conf') 'file /etc/nginx/common/wpcommon-php72.conf')
wo_nginx = open('/etc/nginx/common/wpcommon-php72.conf', wo_nginx = open('/etc/nginx/common/wpcommon-php72.conf',
@@ -282,15 +290,23 @@ def post_pref(self, apt_packages, packages):
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/wprocket-php72.conf')
wo_nginx = open('/etc/nginx/common/wprocket-php72.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'wprocket.mustache',
out=wo_nginx)
wo_nginx.close()
# PHP 7.3 conf # PHP 7.3 conf
if os.path.isdir("/etc/nginx/common"): if os.path.isdir("/etc/nginx/common"):
data = dict() data = dict(upstream="php73")
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/php73.conf') 'file /etc/nginx/common/php73.conf')
wo_nginx = open('/etc/nginx/common/php73.conf', wo_nginx = open('/etc/nginx/common/php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'php7.mustache', self.app.render((data), 'php.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -298,7 +314,7 @@ def post_pref(self, apt_packages, packages):
'file /etc/nginx/common/wpcommon-php73.conf') 'file /etc/nginx/common/wpcommon-php73.conf')
wo_nginx = open('/etc/nginx/common/wpcommon-php73.conf', wo_nginx = open('/etc/nginx/common/wpcommon-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpcommon-php7.mustache', self.app.render((data), 'wpcommon.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -306,7 +322,7 @@ def post_pref(self, apt_packages, packages):
'file /etc/nginx/common/wpfc-php73.conf') 'file /etc/nginx/common/wpfc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpfc-php73.conf', wo_nginx = open('/etc/nginx/common/wpfc-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpfc-php7.mustache', self.app.render((data), 'wpfc.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
@@ -314,26 +330,23 @@ def post_pref(self, apt_packages, packages):
'file /etc/nginx/common/wpsc-php73.conf') 'file /etc/nginx/common/wpsc-php73.conf')
wo_nginx = open('/etc/nginx/common/wpsc-php73.conf', wo_nginx = open('/etc/nginx/common/wpsc-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'wpsc-php7.mustache', self.app.render((data), 'wpsc.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
# create redis conf
data = dict()
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php72.conf') 'file /etc/nginx/common/wprocket-php73.conf')
wo_nginx = open('/etc/nginx/common/redis-php72.conf', wo_nginx = open('/etc/nginx/common/wprocket-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'redis.mustache', self.app.render((data), 'wprocket.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()
data = dict()
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/common/redis-php73.conf') 'file /etc/nginx/common/redis-php73.conf')
wo_nginx = open('/etc/nginx/common/redis-php73.conf', wo_nginx = open('/etc/nginx/common/redis-php73.conf',
encoding='utf-8', mode='w') encoding='utf-8', mode='w')
self.app.render((data), 'redis-php7.mustache', self.app.render((data), 'redis.mustache',
out=wo_nginx) out=wo_nginx)
wo_nginx.close() wo_nginx.close()

View File

@@ -1,4 +1,4 @@
# WordOps admin NGINX CONFIGURATION - WO v3.9.5 # WordOps admin NGINX CONFIGURATION - WO v3.9.7
server { server {

View File

@@ -1,54 +0,0 @@
# 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 {
access_log off;
log_not_found off;
expires max;
}
location = /robots.txt {
# Some WordPress plugin gererate robots.txt file
# Refer #340 issue
try_files $uri $uri/ /index.php$is_args$args @robots;
access_log off;
log_not_found off;
}
# fallback for robots.txt with default wordpress rules
location @robots {
return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n";
}
# Cache static files
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|woff2|ttf|m4a|mp4|ttf|rss|atom|jpe?g|gif|cur|heic|png|tiff|ico|webm|mp3|aac|tgz|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|swf|webp)$ {
add_header "Access-Control-Allow-Origin" "*";
access_log off;
log_not_found off;
expires max;
}
# Cache css & js files
location ~* \.(?:css(\.map)?|js(\.map)?)$ {
add_header "Access-Control-Allow-Origin" "*";
access_log off;
log_not_found off;
expires 30d;
}
# Security settings for better privacy
# Deny hidden files
location ~ /\.(?!well-known\/) {
deny all;
}
# letsencrypt validation
location /.well-known/acme-challenge/ {
alias /var/www/html/.well-known/acme-challenge/;
allow all;
}
# Return 403 forbidden for readme.(txt|html) or license.(txt|html) or example.(txt|html) or other common git repository files
location ~* "/(^$|readme|license|example|README|LEGALNOTICE|INSTALLATION|CHANGELOG)\.(txt|html|md)" {
deny all;
}
# Deny backup extensions & log files and return 403 forbidden
location ~* "\.(old|orig|original|php#|php~|php_bak|save|swo|aspx?|tpl|sh|bash|bak?|cfg|cgi|dll|exe|git|hg|ini|jsp|log|mdb|out|sql|svn|swp|tar|rdf)$" {
deny all;
}
location ~* "/(=|\$&|_mm|(wp-)?config\.|cgi-|etc/passwd|muieblack)" {
deny all;
}

View File

@@ -1,4 +1,4 @@
# NGINX CONFIGURATION FOR COMMON LOCATION - WO v3.9.5 # NGINX CONFIGURATION FOR COMMON LOCATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# Basic locations files # Basic locations files
location = /favicon.ico { location = /favicon.ico {

View File

@@ -1,4 +1,4 @@
# NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION - WO v3.9.5 # NGINX CONFIGURATION FOR FASTCGI_CACHE EXCEPTION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# do not cache xhtml request # do not cache xhtml request
@@ -52,6 +52,11 @@ map $is_args $query_no_cache {
"" 0; "" 0;
} }
map $https $https_prefix {
default "";
on "-https"
}
# if all previous check are passed, $skip_cache = 0 # if all previous check are passed, $skip_cache = 0
map $http_request_no_cache$cookie_no_cache$uri_no_cache$query_no_cache $skip_cache { map $http_request_no_cache$cookie_no_cache$uri_no_cache$query_no_cache $skip_cache {
default 1; default 1;

View File

@@ -1,4 +1,4 @@
# PHP NGINX CONFIGURATION - WO v3.9.5 # PHP NGINX CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
location / { location / {
try_files $uri $uri/ /index.php$is_args$args; try_files $uri $uri/ /index.php$is_args$args;
@@ -6,5 +6,5 @@ location / {
location ~ \.php$ { location ~ \.php$ {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass {{upstream}};
} }

View File

@@ -1,10 +0,0 @@
# 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;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php73;
}

View File

@@ -1,42 +0,0 @@
# 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
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /redis-fetch {
internal ;
set $redis_key $args;
redis_pass redis;
}
location /redis-store {
internal ;
set_unescape_uri $key $arg_key ;
redis2_query set $key $echo_request_body;
redis2_query expire $key 14400;
redis2_pass redis;
}
location ~ \.php$ {
set $key "nginx-cache:$scheme$request_method$host$request_uri";
try_files $uri =404;
srcache_fetch_skip $skip_cache;
srcache_store_skip $skip_cache;
srcache_response_cache_control off;
set_escape_uri $escaped_key $key;
srcache_fetch GET /redis-fetch $key;
srcache_store PUT /redis-store key=$escaped_key;
more_set_headers 'X-SRCache-Fetch-Status $srcache_fetch_status';
more_set_headers 'X-SRCache-Store-Status $srcache_store_status';
include fastcgi_params;
fastcgi_pass php73;
}

View File

@@ -1,4 +1,4 @@
# Redis NGINX CONFIGURATION - WO v3.9.5 # Redis NGINX CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # 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 # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf
@@ -39,5 +39,5 @@ location ~ \.php$ {
more_set_headers 'X-SRCache-Store-Status $srcache_store_status'; more_set_headers 'X-SRCache-Store-Status $srcache_store_status';
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass {{upstream}};
} }

View File

@@ -1,4 +1,4 @@
# NGINX UPSTREAM CONFIGURATION - WO v3.9.5 # NGINX UPSTREAM CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
#------------------------------- #-------------------------------
# PHP 5.6 # PHP 5.6

View File

@@ -49,7 +49,7 @@ server {
} }
{{/static}} {{/static}}
{{^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}} {{^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}}{{#wprocket}}common/wprocket-php73.conf{{/wprocket}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon-php73.conf;{{/wp}} {{#wp}}include common/wpcommon-php73.conf;{{/wp}}
include common/locations-wo.conf;{{/proxy}} include common/locations-wo.conf;{{/proxy}}

View File

@@ -49,7 +49,7 @@ server {
} }
{{/static}} {{/static}}
{{^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}} {{^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}}{{#wprocket}}common/wprocket-php72.conf{{/wprocket}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
{{#wp}}include common/wpcommon-php72.conf;{{/wp}} {{#wp}}include common/wpcommon-php72.conf;{{/wp}}
include common/locations-wo.conf;{{/proxy}} include common/locations-wo.conf;{{/proxy}}

View File

@@ -1,4 +1,4 @@
# WEBP NGINX CONFIGURATION - WO v3.9.5 # WEBP NGINX CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
map $http_accept $webp_suffix { map $http_accept $webp_suffix {

View File

@@ -1,70 +0,0 @@
# 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 {
limit_req zone=one burst=1 nodelay;
include fastcgi_params;
fastcgi_pass php73;
}
# Disable wp-config.txt
location = /wp-config.txt {
deny all;
access_log off;
log_not_found off;
}
location = /robots.txt {
# Some WordPress plugin gererate robots.txt file
# Refer #340 issue
try_files $uri $uri/ /index.php?$args @robots;
access_log off;
log_not_found off;
}
# fallback for robots.txt with default wordpress rules
location @robots {
return 200 "User-agent: *\nDisallow: /wp-admin/\nAllow: /wp-admin/admin-ajax.php\n";
}
# webp rewrite rules for jpg and png images
# try to load alternative image.png.webp before image.png
location /wp-content/uploads {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
add_header "Access-Control-Allow-Origin" "*";
add_header Cache-Control "public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# webp rewrite rules for EWWW testing image
location /wp-content/plugins/ewww-image-optimizer/images {
location ~ \.(png|jpe?g)$ {
add_header Vary "Accept-Encoding";
add_header "Access-Control-Allow-Origin" "*";
add_header Cache-Control "public, no-transform";
access_log off;
log_not_found off;
expires max;
try_files $uri$webp_suffix $uri =404;
}
location ~ \.php$ {
#Prevent Direct Access Of PHP Files From Web Browsers
deny all;
}
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# mitigate DoS attack CVE with WordPress script concatenation
# add the following line to wp-config.php
# define( 'CONCATENATE_SCRIPTS', false );
location ~ \/wp-admin\/load-(scripts|styles).php {
deny all;
}

View File

@@ -1,10 +1,10 @@
# WordPress COMMON SETTINGS - WO v3.9.5 # WordPress COMMON SETTINGS - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE
# Limit access to avoid brute force attack # Limit access to avoid brute force attack
location = /wp-login.php { location = /wp-login.php {
limit_req zone=one burst=1 nodelay; limit_req zone=one burst=1 nodelay;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass {{upstream}};
} }
# Disable wp-config.txt # Disable wp-config.txt
location = /wp-config.txt { location = /wp-config.txt {

View File

@@ -1,21 +0,0 @@
# 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
add_header X-fastcgi-cache $upstream_cache_status;
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php73;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
access_log off;
}

View File

@@ -1,4 +1,4 @@
# WPFC NGINX CONFIGURATION - WO v3.9.5 # WPFC NGINX CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # 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 # $skip_cache variable set in /etc/nginx/conf.d/map-wp.conf
@@ -10,7 +10,7 @@ location / {
location ~ \.php$ { location ~ \.php$ {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass {{upstream}};
fastcgi_cache_bypass $skip_cache; fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache; fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS; fastcgi_cache WORDPRESS;

View File

@@ -0,0 +1,21 @@
# WPSC NGINX CONFIGURATION - WO v3.9.7
# 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
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index$https_prefix.html $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass {{upstream}};
}
location ~* /cache/wp-rocket/\.html$ {
etag on;
add_header Vary "Accept-Encoding, Cookie";
access_log off;
log_not_found off;
expire 10h;
}

View File

@@ -1,17 +0,0 @@
# 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
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
# If we add index.php?$args its break WooCommerce like plugins
# Ref: #330
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass php73;
# Following line is needed by WP Super Cache plugin
fastcgi_param SERVER_NAME $http_host;
}

View File

@@ -1,4 +1,4 @@
# WPSC NGINX CONFIGURATION - WO v3.9.5 # WPSC NGINX CONFIGURATION - WO v3.9.7
# DO NOT MODIFY, ALL CHANGES WILL BE LOST AFTER AN WordOps (wo) UPDATE # 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 # $cache_uri variable set in /etc/nginx/conf.d/map-wp.conf
@@ -11,7 +11,7 @@ location / {
location ~ \.php$ { location ~ \.php$ {
try_files $uri =404; try_files $uri =404;
include fastcgi_params; include fastcgi_params;
fastcgi_pass php72; fastcgi_pass {{upstream}};
# Following line is needed by WP Super Cache plugin # Following line is needed by WP Super Cache plugin
fastcgi_param SERVER_NAME $http_host; fastcgi_param SERVER_NAME $http_host;
} }