Working kvm frontend for vifib proxying

parent 1c13a438
......@@ -247,13 +247,14 @@ class Recipe(BaseSlapRecipe):
rewrite_part = self.substituteTemplate(
self.getTemplateFilename('proxytable-host.json.in'), rewrite_rule)
proxy_table_content = """%s%s,""" % (proxy_table_content, rewrite_part)
proxy_table_content = """%s%s""" % (proxy_table_content,
self.getTemplateFilename('proxytable-vifib-snippet.json.in'))
proxy_table_content = '%s}' % proxy_table_content
proxy_table_content = '%s%s' % (proxy_table_content,
open(self.getTemplateFilename('proxytable-vifib-snippet.json.in')).read())
proxy_table_content = '%s}\n' % proxy_table_content
return proxy_table_content
def installFrontendNode(self, ip, port, key, certificate, plain_http,
name, rewrite_rule_list):
# XXX-Cedric : is name necessary?
# Create Map
map_name = "proxy_table.json"
map_content = self._getProxyTableContent(rewrite_rule_list)
......@@ -261,20 +262,21 @@ class Recipe(BaseSlapRecipe):
self.path_list.append(map_file)
# Install script
kvm_proxy_script_in = pkg_resources.resource_filename(
__name__, os.path.join('template', 'kvm-proxy.js'))
kvm_proxy_script_in = open(self.getTemplateFilename(
'kvm-proxy.js'), 'r').read()
kvm_proxy_script = self.createRunningWrapper("kvm-proxy.js",
kvm_proxy_script_in)
self.path_list.append(kvm_proxy_script)
# Create wrapper
wrapper = zc.buildout.easy_install.scripts([(
name, 'slapos.recipe.librecipe.execute', 'executee_wait')], self.ws,
"kvm_frontend", 'slapos.recipe.librecipe.execute', 'executee_wait')], self.ws,
sys.executable, self.wrapper_directory, arguments=[
self.options['node_binary'].strip(), kvm_proxy_script,
ip, port, key, certificate, plain_http,
[self.options['node_binary'].strip(), kvm_proxy_script,
ip, str(port), key, certificate, map_file, str(plain_http)],
[key, certificate],
{'NODE_PATH': self.options['node_path']}]
)[0]
self.path_list.extend(wrapper)
self.path_list.append(wrapper)
return dict(site_url="https://%s:%s/" % (name, port))
......@@ -3,16 +3,14 @@ var fs = require('fs'),
colors = require('colors'),
http = require('http'),
httpProxy = require('http-proxy'),
process = require('process')
proxyByUrl = require('proxy-by-url');
var proxyTable = 'proxy-table.json',
//listenInterface = '2a01:e34:ec03:8610:60c:ceff:fed1:b9fc',
listenInterface = process.argv[1],
port = process.argv[2],
sslKeyFile = process.argv[3],
sslCertFile = process.argv[4],
redirect = process.argv[5] || false,
var listenInterface = process.argv[2],
port = process.argv[3],
sslKeyFile = process.argv[4],
sslCertFile = process.argv[5],
proxyTable = process.argv[6],
redirect = process.argv[7] || false,
isRawIPv6;
isRawIPv6 = function checkipv6(str) {
......@@ -39,10 +37,8 @@ var middlewareVifib = function(req, res, next) {
// Completely hardcoded rewrite
var vifibPrefix = '/hosting';
if (req.url.indexOf(vifibPrefix) == 0) {
var hostname = 'localhost',
port = '8000';
// Rewrite URL to match virtual host
req.url = vifibPrefix + '/VirtualHostBase/https/' + hostname + ':' + port +
req.url = vifibPrefix + '/VirtualHostBase/https/' + req.headers.host +
'/erp5/web_site_module/VirtualHostRoot' + req.url;
console.log('Vifib rewrite. New URL is : ' + req.url);
}
......
"/domain": {
"port": 4443,
"host":"vifib",
"/hosting": {
"port": 15000,
"host": "2a01:e35:2e27:460:e2cb:4eff:fed9:ddd6",
"https": true
}
......@@ -9,7 +9,9 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
node_path = ${buildout:parts-directory}:${npm-modules:location}/node_modules
recipe = ${instance-recipe:egg}:${instance-recipe:module}
node_binary = ${nodejs:location}/bin/node
npm_binary = ${npm:location}/bin/npm
#npm_binary = ${npm:location}/bin/npm
openssl_binary = ${openssl:location}/bin/openssl
dcrond_binary = ${dcron:location}/sbin/crond
logrotate_binary = ${logrotate:location}/usr/sbin/logrotate
rdiff_backup_binary = ${buildout:bin-directory}/rdiff-backup
......@@ -2,15 +2,19 @@
extends =
../../component/dcron/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/rdiff-backup/buildout.cfg
../../stack/nodejs.cfg
parts =
template
nodejs
npm
http-proxy
proxy-by-url
dcron
logrotate
rdiff-backup
# Buildoutish
eggs
......@@ -47,7 +51,7 @@ recipe = slapos.recipe.build:download-unpacked
url = https://nodeload.github.com/desaintmartin/node-http-proxy/zipball/master
md5sum = 464afcf7a9742f88966b1c5d9164362a
[node-proxy-url]
[proxy-by-url]
# https://github.com/dominictarr/proxy-by-url
recipe = slapos.recipe.build:download-unpacked
#XXX-Cedric : use upstream when merged
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment