fix hsts
This commit is contained in:
@@ -337,7 +337,8 @@ class WOSiteCreateController(CementBaseController):
|
|||||||
choices=('on', 'subdomain', 'wildcard'),
|
choices=('on', 'subdomain', 'wildcard'),
|
||||||
const='on', nargs='?')),
|
const='on', nargs='?')),
|
||||||
(['--hsts'],
|
(['--hsts'],
|
||||||
dict(help="enable HSTS for site secured with letsencrypt")),
|
dict(help="enable HSTS for site secured with letsencrypt",
|
||||||
|
action='store_true')),
|
||||||
(['--user'],
|
(['--user'],
|
||||||
dict(help="provide user for WordPress site")),
|
dict(help="provide user for WordPress site")),
|
||||||
(['--email'],
|
(['--email'],
|
||||||
@@ -675,9 +676,10 @@ class WOSiteCreateController(CementBaseController):
|
|||||||
data['letsencrypt'] = True
|
data['letsencrypt'] = True
|
||||||
letsencrypt = True
|
letsencrypt = True
|
||||||
|
|
||||||
if self.app.pargs.hsts == 'on':
|
if self.app.pargs.hsts:
|
||||||
data['hsts'] = True
|
if self.app.pargs.hsts == "on":
|
||||||
hsts = True
|
data['hsts'] = True
|
||||||
|
hsts = True
|
||||||
|
|
||||||
if data['letsencrypt'] is True:
|
if data['letsencrypt'] is True:
|
||||||
setupLetsEncrypt(self, wo_domain)
|
setupLetsEncrypt(self, wo_domain)
|
||||||
@@ -781,7 +783,7 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
choices=('on', 'off', 'renew', 'subdomain', 'wildcard'),
|
choices=('on', 'off', 'renew', 'subdomain', 'wildcard'),
|
||||||
const='on', nargs='?')),
|
const='on', nargs='?')),
|
||||||
(['--hsts'],
|
(['--hsts'],
|
||||||
dict(help="configure hsts on site secured with letsencrypt",
|
dict(help="configure HSTS on site secured with letsencrypt",
|
||||||
action='store' or 'store_const',
|
action='store' or 'store_const',
|
||||||
choices=('on', 'off'),
|
choices=('on', 'off'),
|
||||||
const='on', nargs='?')),
|
const='on', nargs='?')),
|
||||||
@@ -1111,14 +1113,6 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
data['hsts'] = False
|
data['hsts'] = False
|
||||||
hsts = False
|
hsts = False
|
||||||
|
|
||||||
if pargs.hsts:
|
|
||||||
if pargs.hsts == 'on':
|
|
||||||
data['hsts'] = True
|
|
||||||
hsts = True
|
|
||||||
elif pargs.hsts == 'off':
|
|
||||||
data['hsts'] = False
|
|
||||||
hsts = False
|
|
||||||
|
|
||||||
if letsencrypt is check_ssl:
|
if letsencrypt is check_ssl:
|
||||||
if letsencrypt is False:
|
if letsencrypt is False:
|
||||||
Log.error(self, "SSl is not configured for given "
|
Log.error(self, "SSl is not configured for given "
|
||||||
@@ -1128,6 +1122,14 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
"site")
|
"site")
|
||||||
pargs.letsencrypt = False
|
pargs.letsencrypt = False
|
||||||
|
|
||||||
|
if pargs.hsts:
|
||||||
|
if pargs.hsts == 'on':
|
||||||
|
data['hsts'] = True
|
||||||
|
hsts = True
|
||||||
|
elif pargs.hsts == 'off':
|
||||||
|
data['hsts'] = False
|
||||||
|
hsts = False
|
||||||
|
|
||||||
if data and (not pargs.php73):
|
if data and (not pargs.php73):
|
||||||
if old_php73 is True:
|
if old_php73 is True:
|
||||||
data['php73'] = True
|
data['php73'] = True
|
||||||
@@ -1344,6 +1346,38 @@ class WOSiteUpdateController(CementBaseController):
|
|||||||
updateSiteInfo(self, wo_domain, ssl=letsencrypt)
|
updateSiteInfo(self, wo_domain, ssl=letsencrypt)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if pargs.htsts == "on":
|
||||||
|
if check_ssl:
|
||||||
|
if not os.path.isfile(("{0}/conf/nginx/hsts.conf.disabled")
|
||||||
|
.format(wo_site_webroot)):
|
||||||
|
setupHsts(self, wo_domain)
|
||||||
|
else:
|
||||||
|
WOFileUtils.mvfile(self, "{0}/conf/nginx/"
|
||||||
|
"hsts.conf.disabled"
|
||||||
|
.format(wo_site_webroot),
|
||||||
|
'{0}/conf/nginx/hsts.conf'
|
||||||
|
.format(wo_site_webroot))
|
||||||
|
else:
|
||||||
|
Log.error(self, "HTTPS is not configured for given "
|
||||||
|
"site")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if pargs.htsts == "off":
|
||||||
|
if os.path.isfile(("{0}/conf/nginx/hsts.conf")
|
||||||
|
.format(wo_site_webroot)):
|
||||||
|
WOFileUtils.mvfile(self, "{0}/conf/nginx/"
|
||||||
|
"hsts.conf"
|
||||||
|
.format(wo_site_webroot),
|
||||||
|
'{0}/conf/nginx/hsts.conf.disabled'
|
||||||
|
.format(wo_site_webroot))
|
||||||
|
|
||||||
|
if not WOService.reload_service(self, 'nginx'):
|
||||||
|
Log.error(self, "service nginx reload failed. "
|
||||||
|
"check issues with `nginx -t` command")
|
||||||
|
else:
|
||||||
|
Log.error(self, "HSTS is not configured for given "
|
||||||
|
"site")
|
||||||
|
|
||||||
if stype == oldsitetype and cache == oldcachetype:
|
if stype == oldsitetype and cache == oldcachetype:
|
||||||
|
|
||||||
# Service Nginx Reload
|
# Service Nginx Reload
|
||||||
|
|||||||
Reference in New Issue
Block a user