Skip to content

Commit e83289c

Browse files
committed
update other types of site to proxy
1 parent d3e0b3f commit e83289c

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

ee/cli/plugins/site.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,8 @@ class Meta:
654654
dict(help='Use PageSpeed for site',
655655
action='store' or 'store_const',
656656
choices=('on', 'off'), const='on', nargs='?')),
657+
(['--proxy'],
658+
dict(help="update to prxy site", nargs='+')),
657659
(['--all'],
658660
dict(help="update all sites", action='store_true')),
659661
]
@@ -701,6 +703,21 @@ def doupdatesite(self, pargs):
701703
Log.error(self, "Please provide valid options combination for"
702704
" site update")
703705

706+
if stype is None and pargs.proxy:
707+
stype, cache = 'proxy', ''
708+
proxyinfo = pargs.proxy[0].strip()
709+
if not proxyinfo:
710+
Log.error(self, "Please provide proxy server host information")
711+
proxyinfo = proxyinfo.split(':')
712+
host = proxyinfo[0].strip()
713+
port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
714+
elif stype is None and not pargs.proxy:
715+
stype, cache = 'html', 'basic'
716+
elif stype and pargs.proxy:
717+
Log.error(self, "--proxy can not be used with other site types")
718+
if (pargs.proxy and (pargs.pagespeed or pargs.hhvm)):
719+
Log.error(self, "Proxy site can not run on pagespeed or hhvm")
720+
704721
if not pargs.site_name:
705722
try:
706723
while not pargs.site_name:
@@ -757,6 +774,18 @@ def doupdatesite(self, pargs):
757774
format(oldsitetype, oldcachetype, stype, cache))
758775
return 1
759776

777+
if stype == 'proxy':
778+
data['site_name'] = ee_domain
779+
data['www_domain'] = ee_www_domain
780+
data['proxy'] = True
781+
data['host'] = host
782+
data['port'] = port
783+
pagespeed = False
784+
hhvm = False
785+
data['webroot'] = ee_site_webroot
786+
data['currsitetype'] = oldsitetype
787+
data['currcachetype'] = oldcachetype
788+
760789
if stype == 'php':
761790
data = dict(site_name=ee_domain, www_domain=ee_www_domain,
762791
static=False, basic=True, wp=False, w3tc=False,
@@ -926,6 +955,13 @@ def doupdatesite(self, pargs):
926955
"`tail /var/log/ee/ee.log` & Try Again!!!")
927956
return 1
928957

958+
if 'proxy' in data.keys() and data['proxy']:
959+
updateSiteInfo(self, ee_domain, stype=stype, cache=cache,
960+
hhvm=hhvm, pagespeed=pagespeed)
961+
Log.info(self, "Successfully updated site"
962+
" http://{0}".format(ee_domain))
963+
return 0
964+
929965
# Update pagespeed config
930966
if pargs.pagespeed:
931967
operateOnPagespeed(self, data)

ee/cli/plugins/site_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def sitebackup(self, data):
520520
EEFileUtils.copyfile(self, '/etc/nginx/sites-available/{0}'
521521
.format(data['site_name']), backup_path)
522522

523-
if data['currsitetype'] in ['html', 'php', 'mysql']:
523+
if data['currsitetype'] in ['html', 'php', 'proxy', 'mysql']:
524524
Log.info(self, "Backing up Webroot \t\t", end='')
525525
EEFileUtils.mvfile(self, ee_site_webroot + '/htdocs', backup_path)
526526
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
@@ -544,7 +544,7 @@ def sitebackup(self, data):
544544
raise SiteError("mysqldump failed to backup database")
545545
Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
546546
# move wp-config.php/ee-config.php to backup
547-
if data['currsitetype'] in ['mysql']:
547+
if data['currsitetype'] in ['mysql', 'proxy']:
548548
EEFileUtils.mvfile(self, configfiles[0], backup_path)
549549
else:
550550
EEFileUtils.copyfile(self, configfiles[0], backup_path)

ee/cli/templates/virtualconf.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server {
1919
{{#proxy}}
2020
add_header X-Proxy-Cache $upstream_cache_status;
2121
location / {
22-
proxy_pass {{host}}:{{port}};
22+
proxy_pass http://{{host}}:{{port}};
2323
proxy_redirect off;
2424
proxy_set_header Host $host;
2525
proxy_set_header X-Real-IP $remote_addr;

0 commit comments

Comments
 (0)