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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos
Commits
a50b5af2
Commit
a50b5af2
authored
Oct 07, 2021
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.cookbook: remove generic-varnish recipe
parent
62955a5d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
0 additions
and
339 deletions
+0
-339
setup.py
setup.py
+0
-1
slapos/recipe/README.generic_varnish.rst
slapos/recipe/README.generic_varnish.rst
+0
-42
slapos/recipe/generic_varnish/__init__.py
slapos/recipe/generic_varnish/__init__.py
+0
-101
slapos/recipe/generic_varnish/template/default.vcl.in
slapos/recipe/generic_varnish/template/default.vcl.in
+0
-142
slapos/recipe/generic_varnish/template/stunnel.conf.in
slapos/recipe/generic_varnish/template/stunnel.conf.in
+0
-9
slapos/recipe/generic_varnish/template/stunnel.in
slapos/recipe/generic_varnish/template/stunnel.in
+0
-3
slapos/recipe/generic_varnish/template/varnishd.in
slapos/recipe/generic_varnish/template/varnishd.in
+0
-15
slapos/recipe/generic_varnish/template/varnishlog.in
slapos/recipe/generic_varnish/template/varnishlog.in
+0
-5
slapos/recipe/generic_varnish/template/varnishlogd.in
slapos/recipe/generic_varnish/template/varnishlogd.in
+0
-21
No files found.
setup.py
View file @
a50b5af2
...
...
@@ -110,7 +110,6 @@ setup(name=name,
'generic.kumofs = slapos.recipe.generic_kumofs:Recipe'
,
'generic.memcached = slapos.recipe.generic_memcached:Recipe'
,
'generic.mysql.wrap_update_mysql = slapos.recipe.generic_mysql:WrapUpdateMySQL'
,
'generic.varnish = slapos.recipe.generic_varnish:Recipe'
,
'gitinit = slapos.recipe.gitinit:Recipe'
,
'haproxy = slapos.recipe.haproxy:Recipe'
,
'ipv4toipv6 = slapos.recipe.6tunnel:FourToSix'
,
...
...
slapos/recipe/README.generic_varnish.rst
deleted
100644 → 0
View file @
62955a5d
generic_varnish
===============
This recipe creates a varnish instance dedicated for ERP5 with a web checker[1]
set up.
How to Use generic_varnish ?
============================
On slap console, you can instantiate varnish like this::
instance = request(
software_type='varnish',
partition_parameter_kw={
'backend-url':'https://[your_backend_address]:your_backend_port',
'web-checker-frontend-url':'http://www.example.com',
'web-checker-mail-address':'web-checker-result@example.com',
'web-checker-smtp-host':'mail.example.com',
}
)
backend-url is the backend url that varnish will cache.
web-checker-frontend-url is the entry-point-url that web checker will check
the HTTP headers of all the pages in the web site.
web-checker-mail-address is the email address where web checker will send
the HTTP Cache cheking result.
web-checker-smtp-host is the smtp server to be used to send the web checker
result.
[Note]
When web-checker-* parameters are not given, web_checker will be disabled.
References
==========
[1] web_checker (it is a part of erp5.util)
http://pypi.python.org/pypi/erp5.util
web_checker: Web site HTTP Cache header checking tool
slapos/recipe/generic_varnish/__init__.py
deleted
100644 → 0
View file @
62955a5d
##############################################################################
#
# Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
os
import
re
from
slapos.recipe.librecipe
import
GenericSlapRecipe
class
Recipe
(
GenericSlapRecipe
):
"""
Instantiate varnish daemon
TODO:
- use varnish3.x and replace .vcl for it
"""
def
_install
(
self
):
ip
=
self
.
options
[
'ip'
]
backend_url
=
self
.
options
.
get
(
'backend-url'
,
# BBB: Peeking in partition parameters directly. Eew.
self
.
parameter_dict
.
get
(
'backend-url'
,
self
.
parameter_dict
.
get
(
'tidstorage-url'
)
# BBB
)
)
backend_server
,
backend_port
=
self
.
_getBackendServer
(
backend_url
)
path_list
=
[]
if
backend_url
.
startswith
(
'https://'
):
config
=
dict
(
stunnel_binary
=
self
.
options
[
'stunnel-binary'
],
stunnel_server
=
ip
,
stunnel_port
=
int
(
self
.
options
[
'stunnel-port'
]),
stunnel_pid_file
=
self
.
options
[
'stunnel-pid-file'
],
stunnel_conf_file
=
self
.
options
[
'stunnel-conf-file'
],
shell_path
=
self
.
options
[
'shell-path'
],
backend_server
=
backend_server
.
replace
(
'['
,
''
).
replace
(
']'
,
''
),
backend_port
=
backend_port
,
)
path_list
.
append
(
self
.
createExecutable
(
self
.
options
[
'stunnel-wrapper'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'stunnel.in'
),
config
)))
path_list
.
append
(
self
.
createFile
(
self
.
options
[
'stunnel-conf-file'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'stunnel.conf.in'
),
config
)))
backend_server
=
ip
backend_port
=
int
(
self
.
options
[
'stunnel-port'
])
varnishd_manager_port
=
int
(
self
.
options
[
'manager-port'
])
varnishd_server_port
=
int
(
self
.
options
[
'server-port'
])
config
=
dict
(
varnishd_binary
=
self
.
options
[
'varnishd-binary'
],
varnish_ip
=
ip
,
varnishlog_binary
=
self
.
options
[
'varnishlog-binary'
],
varnishd_manager_port
=
varnishd_manager_port
,
varnishd_server_port
=
varnishd_server_port
,
varnishd_pid_file
=
self
.
options
[
'pid-file'
],
varnish_instance_name
=
self
.
options
[
'varnish-instance-name'
],
varnish_data
=
self
.
options
[
'varnish-data'
],
gcc_location
=
self
.
options
[
'gcc-location'
],
shell_path
=
self
.
options
[
'shell-path'
],
vcl_file
=
self
.
options
[
'vcl-file'
],
backend_port
=
backend_port
,
backend_server
=
backend_server
,
)
path_list
.
append
(
self
.
createExecutable
(
self
.
options
[
'varnishd-wrapper'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'varnishd.in'
),
config
)))
path_list
.
append
(
self
.
createExecutable
(
self
.
options
[
'varnishlog-wrapper'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'varnishlog.in'
),
config
)))
path_list
.
append
(
self
.
createFile
(
self
.
options
[
'vcl-file'
],
self
.
substituteTemplate
(
self
.
getTemplateFilename
(
'default.vcl.in'
),
config
)))
return
path_list
def
_getBackendServer
(
self
,
url
):
r
=
re
.
compile
(
'
\
/
\
/(
\
[.+
\
]|[
\
d.]+):(
\
d*)'
)
result
=
r
.
search
(
url
)
ip
=
result
.
groups
()[
0
]
port
=
result
.
groups
()[
1
]
return
(
ip
,
port
)
slapos/recipe/generic_varnish/template/default.vcl.in
deleted
100644 → 0
View file @
62955a5d
#This is a basic VCL configuration file for varnish. See the vcl(7)
#man page for details on VCL syntax and semantics.
#
#Default backend definition. Set this to point to your content
#server.
#
backend default {
.host = "%(backend_server)s";
.port = "%(backend_port)s";
.probe = {
.timeout = 30s;
.interval = 5s;
.window = 4;
.threshold = 3;
.request =
"OPTIONS /erp5/getId HTTP/1.1"
"Host: %(backend_server)s:%(backend_port)s"
"Accept-Encoding: identity"
"Connection: close"
"User-Agent: Varnish";
}
}
# Called at the beginning of a request, after the complete request has been received and parsed
sub vcl_recv {
# Pass any requests that Varnish does not understand straight to the backend.
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "PURGE" &&
req.request != "DELETE") {
/* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
# Pass anything other than GET and HEAD directly.
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}
if (req.http.Authorization) {
/* Not cacheable by default */
return (pass);
}
# No need to have cookies for static resources
if (req.url ~ "\.(css|gif|ico|jpg|js|png)$") {
unset req.http.Cookie;
}
# Remove bogus cookies
if (req.http.Cookie) {
set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__utm.=[^;]+;? *", "\1");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__ac_name=\x22\x22;? *", "\1");
set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__ac=\x22Og.3D.3D\x22;? *", "\1");
}
if (req.http.Cookie == "") {
unset req.http.Cookie;
}
if (req.http.Cookie && req.http.Cookie ~ "(^|; ) *__ac=") {
return (pass);
}
# We do not care about Accept-Encoding, because we don't use varnish as the front most HTTP server.
unset req.http.Accept-Encoding;
if (req.backend.healthy) {
set req.grace = 1h;
} else {
set req.grace = 1w;
}
return (lookup);
}
# Run after a pass in vcl_recv OR after a lookup that returned a hitpass
sub vcl_pass {
# unset If-Modified-Since to avoid reusing anonymous's browser cache
# after login.
unset req.http.If-Modified-Since;
return (pass);
}
# Creates the varnish cache key by the url
sub vcl_hash {
# We use url only for hash.
hash_data(req.url);
return (hash);
}
# Called after a cache lookup if the requested document was found in the cache
sub vcl_hit {
return (deliver);
}
# Called after a cache lookup if the requested document was not found in the cache
sub vcl_miss {
return (fetch);
}
# Called after a document has been successfully retrieved from the backend
sub vcl_fetch {
# Unset Expires that is always overridden by Cache-Control.
unset beresp.http.Expires;
# Unset Pragma that is obsolete.
unset beresp.http.Pragma;
# We only cache 200 (OK) and 304 (Not Modified) responses.
if (beresp.status != 200 && beresp.status != 304) {
set beresp.ttl = 0s;
}
# If max-age is 0 or not set, we want no browser cache.
if (beresp.ttl <= 0s) {
set beresp.http.Cache-Control = "no-store";
# Mark as hit_for_pass for the next 2 minutes.
set beresp.ttl = 120s;
return (hit_for_pass);
}
# We don't care haproxy's cookie.
if (beresp.http.Set-Cookie && beresp.http.Set-Cookie !~ "^SERVERID=[^;]+; path=/$") {
return (hit_for_pass);
} else {
unset beresp.http.Set-Cookie;
}
# We set long enough grace for cachable objects.
set beresp.grace = 1w;
return (deliver);
}
# Called before a cached object is delivered to the client
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = obj.hits;
} else {
set resp.http.X-Cache = "MISS";
}
return (deliver);
}
slapos/recipe/generic_varnish/template/stunnel.conf.in
deleted
100644 → 0
View file @
62955a5d
foreground = yes
pid = %(stunnel_pid_file)s
debug = 4
[remote]
accept = %(stunnel_server)s:%(stunnel_port)s
client = yes
connect = %(backend_server)s:%(backend_port)s
sni = %(stunnel_server)s
slapos/recipe/generic_varnish/template/stunnel.in
deleted
100644 → 0
View file @
62955a5d
#!%(shell_path)s
DAEMON_OPTS="%(stunnel_conf_file)s"
exec %(stunnel_binary)s ${DAEMON_OPTS} 2>&1
slapos/recipe/generic_varnish/template/varnishd.in
deleted
100644 → 0
View file @
62955a5d
#!%(shell_path)s
DAEMON_OPTS="-F \
-a %(varnish_ip)s:%(varnishd_server_port)s \
-T %(varnish_ip)s:%(varnishd_manager_port)s \
-t 0 \
-p nuke_limit=500 \
-n %(varnish_instance_name)s \
-f %(vcl_file)s \
-s file,%(varnish_data)s/varnish_storage.bin,1G"
PIDFILE=%(varnishd_pid_file)s
# exporting PATH here so that we will pass the PATH variable to the subprocess
export PATH="%(gcc_location)s:$PATH"
exec %(varnishd_binary)s -P ${PIDFILE} ${DAEMON_OPTS} 2>&1
slapos/recipe/generic_varnish/template/varnishlog.in
deleted
100644 → 0
View file @
62955a5d
#!%(shell_path)s
DAEMON_OPTS="-a -n %(varnish_instance_name)s"
exec %(varnishlog_binary)s ${DAEMON_OPTS} "$@"
slapos/recipe/generic_varnish/template/varnishlogd.in
deleted
100644 → 0
View file @
62955a5d
#!%(shell_path)s
DAEMON_OPTS="-F \
-a %(varnish_ip)s:%(varnishd_server_port)s \
-T %(varnish_ip)s:%(varnishd_manager_port)s \
-n %(varnish_instance_name)s \
-f %(vcl_file)s \
-s file,%(varnish_data)s/varnish_storage.bin,1G"
PIDFILE=%(varnishd_pid_file)s
# exporting PATH here so that it will pass the PATH variable to the subprocess
export PATH
# If unset, or set to "0" or "no", exit
if [ -z "${VARNISHLOG_ENABLED}" ] || \
[ "${VARNISHLOG_ENABLED}" = "0" ] || \
[ "${VARNISHLOG_ENABLED}" = "no" ]; then
exit 0;
fi
exec %(varnishlog_binary)s ${DAEMON_OPTS} 2>&1
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