Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Leo Le Bouter
slapos
Commits
06402ffa
Commit
06402ffa
authored
Dec 08, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working kvm frontend for vifib proxying
parent
1c13a438
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
25 deletions
+30
-25
slapos/recipe/kvm_frontend/__init__.py
slapos/recipe/kvm_frontend/__init__.py
+11
-9
slapos/recipe/kvm_frontend/template/kvm-proxy.js
slapos/recipe/kvm_frontend/template/kvm-proxy.js
+7
-11
slapos/recipe/kvm_frontend/template/proxytable-vifib-snippet.json.in
...pe/kvm_frontend/template/proxytable-vifib-snippet.json.in
+4
-3
software/kvm-frontend/instance.cfg
software/kvm-frontend/instance.cfg
+3
-1
software/kvm-frontend/software.cfg
software/kvm-frontend/software.cfg
+5
-1
No files found.
slapos/recipe/kvm_frontend/__init__.py
View file @
06402ffa
...
...
@@ -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_f
ilename
(
__name__
,
os
.
path
.
join
(
'template'
,
'kvm-proxy.js'
)
)
kvm_proxy_script_in
=
open
(
self
.
getTemplateF
ilename
(
'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
.
ext
end
(
wrapper
)
self
.
path_list
.
app
end
(
wrapper
)
return
dict
(
site_url
=
"https://%s:%s/"
%
(
name
,
port
))
slapos/recipe/kvm_frontend/template/kvm-proxy.js
View file @
06402ffa
...
...
@@ -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
+
'
:
'
+
por
t
+
req
.
url
=
vifibPrefix
+
'
/VirtualHostBase/https/
'
+
req
.
headers
.
hos
t
+
'
/erp5/web_site_module/VirtualHostRoot
'
+
req
.
url
;
console
.
log
(
'
Vifib rewrite. New URL is :
'
+
req
.
url
);
}
...
...
slapos/recipe/kvm_frontend/template/proxytable-vifib-snippet.json.in
View file @
06402ffa
"/
domain
": {
"port":
4443
,
"host":
"vifib
",
"/
hosting
": {
"port":
15000
,
"host":
"2a01:e35:2e27:460:e2cb:4eff:fed9:ddd6
",
"https": true
}
software/kvm-frontend/instance.cfg
View file @
06402ffa
...
...
@@ -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
software/kvm-frontend/software.cfg
View file @
06402ffa
...
...
@@ -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-prox
y-url]
[
proxy-b
y-url]
# https://github.com/dominictarr/proxy-by-url
recipe = slapos.recipe.build:download-unpacked
#XXX-Cedric : use upstream when merged
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment