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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos
Commits
41d6bf1f
Commit
41d6bf1f
authored
Jul 15, 2011
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code to create only one file to define all virtual hosts
parent
696e48f2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
slapos/recipe/apache/__init__.py
slapos/recipe/apache/__init__.py
+12
-13
slapos/recipe/apache/template/apache.conf.in
slapos/recipe/apache/template/apache.conf.in
+1
-1
No files found.
slapos/recipe/apache/__init__.py
View file @
41d6bf1f
...
...
@@ -64,7 +64,7 @@ class Recipe(BaseSlapRecipe):
port
=
8080
,
name
=
frontend_domain_name
,
key
=
key
,
certificate
=
certificate
)
self
.
setConnectionDict
(
dict
(
site_url
=
site_url
,
))
self
.
setConnectionDict
(
dict
(
site_url
=
site_url
))
return
self
.
path_list
def
installLogrotate
(
self
):
...
...
@@ -203,23 +203,22 @@ class Recipe(BaseSlapRecipe):
apache_conf
[
'pid_file'
]
+
' SIGUSR1'
)
return
apache_conf
def
generateNewId
(
self
):
"""Temporary way to generate id"""
import
random
return
str
(
random
.
randint
(
2
**
9
,
9
**
9
))
def
generateRewriteRule
(
self
,
parameter_dict
):
return
"RewriteRule ^/%(id)s($|/.*) %(url)s/VirtualHostBase/"
%
parameter_dict
+
\
"https/%(domain)s:%(port)s/VirtualHostRoot/_vh_%(id)s$1 [L,P]"
%
parameter_dict
def
installFrontendApache
(
self
,
ip
,
port
,
key
,
certificate
,
name
,
access_control_string
=
None
):
rewrite_rule_include_path
=
self
.
createDataDirectory
(
'apachevhost'
)
vhost_name
=
"apachevhost.conf"
slave_instance_list
=
self
.
parameter_dict
.
get
(
"slave_instance_list"
,
[])
rewrite_rule_list
=
[]
for
slave_instance
in
slave_instance_list
:
id
=
self
.
generateNewId
()
url
=
slave_instance
.
get
(
"url"
)
rewrite_rule_content
=
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'apache.vhost.conf.in'
)
,
dict
(
id
=
id
,
ip
=
ip
,
port
=
port
,
domain
=
name
,
url
=
url
)
)
self
.
_writeFile
(
os
.
path
.
join
(
rewrite_rule_include_path
,
id
),
rewrite_rule_content
)
id
=
str
(
slave_instance_list
.
index
(
slave_instance
))
vhost_dict
=
dict
(
id
=
id
,
ip
=
ip
,
port
=
port
,
domain
=
name
,
url
=
url
)
rewrite_rule_list
.
append
(
self
.
generateRewriteRule
(
vhost_dict
))
self
.
createConfigurationFile
(
vhost_name
,
"
\
n
"
.
join
(
rewrite_rule_list
)
)
apache_conf
=
self
.
_getApacheConfigurationDict
(
name
,
ip
,
port
)
apache_conf
[
'ssl_snippet'
]
=
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'apache.ssl-snippet.conf.in'
),
...
...
@@ -231,7 +230,7 @@ class Recipe(BaseSlapRecipe):
apache_conf
.
update
(
**
dict
(
path_enable
=
path
,
rewrite_rule_
include_path
=
rewrite_rule_include_path
rewrite_rule_
path
=
os
.
path
.
join
(
self
.
etc_directory
,
vhost_name
),
))
apache_conf_string
=
self
.
substituteTemplate
(
...
...
slapos/recipe/apache/template/apache.conf.in
View file @
41d6bf1f
...
...
@@ -37,7 +37,7 @@ CustomLog "%(access_log)s" common
# Magic of Zope related rewrite
RewriteEngine On
Include %(rewrite_rule_
include_path)s/*.conf
Include %(rewrite_rule_
path)s
# List of modules
LoadModule authz_host_module modules/mod_authz_host.so
...
...
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