Browse Source

Now pagespeed common config is created to webroot/conf/nginx/pagespeed.conf

bugfixes
gau1991 10 years ago
parent
commit
e40f990e90
  1. 8
      ee/cli/plugins/site.py
  2. 41
      ee/cli/plugins/site_functions.py
  3. 11
      ee/cli/plugins/stack.py
  4. 37
      ee/cli/templates/pagespeed-common.mustache
  5. 2
      ee/cli/templates/virtualconf.mustache

8
ee/cli/plugins/site.py

@ -401,6 +401,10 @@ class EESiteCreateController(CementBaseController):
Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
# Update pagespeed config
if self.app.pargs.pagespeed:
operateOnPagespeed(self, data)
addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed)
# Setup database for MySQL site
@ -780,6 +784,10 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Update site failed. Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!")
# Update pagespeed config
if self.app.pargs.pagespeed:
operateOnPagespeed(self, data)
if stype == oldsitetype and cache == oldcachetype:
# Service Nginx Reload

41
ee/cli/plugins/site_functions.py

@ -587,15 +587,6 @@ def site_package_check(self, stype):
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file /etc/nginx/common/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/common/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
return(stack.install(apt_packages=apt_packages, packages=packages,
disp_msg=False))
@ -861,3 +852,35 @@ def doCleanupAction(self, domain='', webroot='', dbname='', dbuser='',
if not dbhost:
raise SiteError("dbhost not provided")
deleteDB(self, dbname, dbuser, dbhost)
def operateOnPagespeed(self, data):
ee_domain_name = data['site_name']
ee_site_webroot = data['webroot']
if data['pagespeed'] is True:
if not os.path.isfile("{0}/conf/nginx/pagespeed.conf.disabled"
.format(ee_site_webroot)):
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file {0}/conf/nginx/pagespeed.conf'
'pagespeed.conf'.format(ee_site_webroot))
ee_nginx = open('{0}/conf/nginx/pagespeed.conf'
.format(ee_site_webroot), encoding='utf-8',
mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
else:
EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf.disabled"
.format(ee_site_webroot),
'{0}/conf/nginx/pagespeed.conf'
.format(ee_site_webroot))
elif data['pagespeed'] is False:
if os.path.isfile("{0}/conf/nginx/pagespeed.conf"
.format(ee_site_webroot)):
EEFileUtils.mvfile(self, "{0}/conf/nginx/pagespeed.conf"
.format(ee_site_webroot),
'{0}/conf/nginx/pagespeed.conf.disabled'
.format(ee_site_webroot))

11
ee/cli/plugins/stack.py

@ -362,15 +362,6 @@ class EEStackController(CementBaseController):
out=ee_nginx)
ee_nginx.close()
Log.debug(self, 'Writting the Pagespeed common '
'configuration to file /etc/nginx/common/'
'pagespeed.conf')
ee_nginx = open('/etc/nginx/common/pagespeed.conf',
encoding='utf-8', mode='w')
self.app.render((data), 'pagespeed-common.mustache',
out=ee_nginx)
ee_nginx.close()
# 22222 port settings
Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/sites-available/'
@ -1793,7 +1784,7 @@ class EEStackController(CementBaseController):
Log.info(self, "Purging packages, please wait ...")
EEAptGet.remove(self, apt_packages, purge=True)
EEAptGet.auto_remove(self)
if len(packages):
if ee_prompt == 'YES' or ee_prompt == 'yes':
EEFileUtils.remove(self, packages)

37
ee/cli/templates/pagespeed-common.mustache

@ -1,19 +1,3 @@
# PageSpeed Admin
location /ngx_pagespeed_statistics { include common/acl.conf; }
location /ngx_pagespeed_global_statistics { include common/acl.conf; }
location /ngx_pagespeed_message { include common/acl.conf; }
location /pagespeed_console { include common/acl.conf; }
location ~ ^/pagespeed_admin { include common/acl.conf; }
location ~ ^/pagespeed_global_admin { include common/acl.conf; }
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
# HTTPS Support
# pagespeed FetchHttps enable;
@ -37,3 +21,24 @@ location ~ "^/ngx_pagespeed_beacon$" { }
# CDN Support
#pagespeed MapRewriteDomain cdn.example.com www.example.com;
###########################################################################################################################
# DO NOT EDIT AFTER THIS LINE #
###########################################################################################################################
# PageSpeed Admin
location /ngx_pagespeed_statistics { include common/acl.conf; }
location /ngx_pagespeed_global_statistics { include common/acl.conf; }
location /ngx_pagespeed_message { include common/acl.conf; }
location /pagespeed_console { include common/acl.conf; }
location ~ ^/pagespeed_admin { include common/acl.conf; }
location ~ ^/pagespeed_global_admin { include common/acl.conf; }
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

2
ee/cli/templates/virtualconf.mustache

@ -30,6 +30,6 @@ server {
{{^static}}include{{/static}} {{^hhvm}}{{#basic}}common/php.conf;{{/basic}}{{#w3tc}}common/w3tc.conf;{{/w3tc}}{{#wpfc}}common/wpfc.conf;{{/wpfc}} {{#wpsc}}common/wpsc.conf;{{/wpsc}} {{/hhvm}}{{#hhvm}}{{#basic}}common/php-hhvm.conf;{{/basic}}{{#w3tc}}common/w3tc-hhvm.conf;{{/w3tc}}{{#wpfc}}common/wpfc-hhvm.conf;{{/wpfc}} {{#wpsc}}common/wpsc-hhvm.conf;{{/wpsc}} {{/hhvm}}
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}
{{#wp}}include common/wpcommon.conf;{{/wp}}
{{#pagespeed}}include common/pagespeed.conf;{{/pagespeed}}
include common/locations.conf;
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}
}

Loading…
Cancel
Save