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. 9
      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 " Log.error(self, "Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`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, addNewSite(self, ee_domain, stype, cache, ee_site_webroot,
hhvm=hhvm, pagespeed=pagespeed) hhvm=hhvm, pagespeed=pagespeed)
# Setup database for MySQL site # Setup database for MySQL site
@ -780,6 +784,10 @@ class EESiteUpdateController(CementBaseController):
Log.error(self, "Update site failed. Check logs for reason " Log.error(self, "Update site failed. Check logs for reason "
"`tail /var/log/ee/ee.log` & Try Again!!!") "`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: if stype == oldsitetype and cache == oldcachetype:
# Service Nginx Reload # Service Nginx Reload

41
ee/cli/plugins/site_functions.py

@ -587,15 +587,6 @@ def site_package_check(self, stype):
out=ee_nginx) out=ee_nginx)
ee_nginx.close() 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, return(stack.install(apt_packages=apt_packages, packages=packages,
disp_msg=False)) disp_msg=False))
@ -861,3 +852,35 @@ def doCleanupAction(self, domain='', webroot='', dbname='', dbuser='',
if not dbhost: if not dbhost:
raise SiteError("dbhost not provided") raise SiteError("dbhost not provided")
deleteDB(self, dbname, dbuser, dbhost) 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))

9
ee/cli/plugins/stack.py

@ -362,15 +362,6 @@ class EEStackController(CementBaseController):
out=ee_nginx) out=ee_nginx)
ee_nginx.close() 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 # 22222 port settings
Log.debug(self, 'Writting the nginx configuration to ' Log.debug(self, 'Writting the nginx configuration to '
'file /etc/nginx/sites-available/' 'file /etc/nginx/sites-available/'

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 # HTTPS Support
# pagespeed FetchHttps enable; # pagespeed FetchHttps enable;
@ -37,3 +21,24 @@ location ~ "^/ngx_pagespeed_beacon$" { }
# CDN Support # CDN Support
#pagespeed MapRewriteDomain cdn.example.com www.example.com; #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}} {{^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}} {{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}
{{#wp}}include common/wpcommon.conf;{{/wp}} {{#wp}}include common/wpcommon.conf;{{/wp}}
{{#pagespeed}}include common/pagespeed.conf;{{/pagespeed}}
include common/locations.conf; include common/locations.conf;
{{^vma}}{{^rc}}include {{webroot}}/conf/nginx/*.conf;{{/rc}}{{/vma}}
} }

Loading…
Cancel
Save