Commit 836768fd authored by Łukasz Nowak's avatar Łukasz Nowak

rapid-cdn: c->h: Implement not found instance

parent e5b2a05c
...@@ -22,7 +22,7 @@ md5sum = 5784bea3bd608913769ff9a8afcccb68 ...@@ -22,7 +22,7 @@ md5sum = 5784bea3bd608913769ff9a8afcccb68
[profile-frontend] [profile-frontend]
filename = instance-frontend.cfg.in filename = instance-frontend.cfg.in
md5sum = 3eb6adca77906f7b2c40b6f7f28c4bec md5sum = b519b264956ad6ee43615ee535f41e6d
[profile-master] [profile-master]
filename = instance-master.cfg.in filename = instance-master.cfg.in
...@@ -38,7 +38,7 @@ md5sum = cba4d995962f7fbeae3f61c9372c4181 ...@@ -38,7 +38,7 @@ md5sum = cba4d995962f7fbeae3f61c9372c4181
[template-frontend-haproxy-configuration] [template-frontend-haproxy-configuration]
_update_hash_filename_ = templates/frontend-haproxy.cfg.in _update_hash_filename_ = templates/frontend-haproxy.cfg.in
md5sum = d115e229b7b76bcc6aba4ba62e887ccb md5sum = cab77efb4f7a3bd0a932055d33583640
[template-frontend-haproxy-crt-list] [template-frontend-haproxy-crt-list]
_update_hash_filename_ = templates/frontend-haproxy-crt-list.in _update_hash_filename_ = templates/frontend-haproxy-crt-list.in
...@@ -46,7 +46,7 @@ md5sum = f444c9735e5247faba26831fda6f27f9 ...@@ -46,7 +46,7 @@ md5sum = f444c9735e5247faba26831fda6f27f9
[template-not-found-html] [template-not-found-html]
_update_hash_filename_ = templates/notfound.html _update_hash_filename_ = templates/notfound.html
md5sum = 88af61e7abbf30dc99a1a2526161128d md5sum = d56e2cfab274cbbbe5b387f2f6e417df
[template-backend-haproxy-configuration] [template-backend-haproxy-configuration]
_update_hash_filename_ = templates/backend-haproxy.cfg.in _update_hash_filename_ = templates/backend-haproxy.cfg.in
......
...@@ -423,7 +423,6 @@ extra-context = ...@@ -423,7 +423,6 @@ extra-context =
key global_ipv6 slap-configuration:ipv6-random key global_ipv6 slap-configuration:ipv6-random
key local_ipv4 :local_ipv4 key local_ipv4 :local_ipv4
key error_log frontend-haproxy-configuration:error-log key error_log frontend-haproxy-configuration:error-log
key not_found_file frontend-haproxy-configuration:not-found-file
key username monitor-instance-parameter:username key username monitor-instance-parameter:username
key password monitor-htpasswd:passwd key password monitor-htpasswd:passwd
# BBB: SlapOS Master non-zero knowledge BEGIN # BBB: SlapOS Master non-zero knowledge BEGIN
...@@ -458,7 +457,7 @@ access-log = ${directory:log}/frontend-access.log ...@@ -458,7 +457,7 @@ access-log = ${directory:log}/frontend-access.log
error-log = ${directory:log}/frontend-error.log error-log = ${directory:log}/frontend-error.log
pid-file = ${directory:run}/httpd.pid pid-file = ${directory:run}/httpd.pid
frontend-graceful-command = ${frontend-haproxy-validate:output} && kill -USR2 $(cat ${:pid-file}) frontend-graceful-command = ${frontend-haproxy-validate:output} && kill -USR2 $(cat ${:pid-file})
not-found-file = ${frontend-directory:document-root}/${not-found-html:filename} not-found-file = {{ software_parameter_dict['template_not_found_html'] }}
master-certificate = ${frontend-directory:master-autocert-dir}/master.pem master-certificate = ${frontend-directory:master-autocert-dir}/master.pem
self-signed-fallback-certificate = ${self-signed-fallback-access:certificate} self-signed-fallback-certificate = ${self-signed-fallback-access:certificate}
http-port = ${configuration:plain_http_port} http-port = ${configuration:plain_http_port}
...@@ -499,15 +498,8 @@ context = ...@@ -499,15 +498,8 @@ context =
output = ${directory:bbb-ssl-dir}/frontend.crt output = ${directory:bbb-ssl-dir}/frontend.crt
# BBB: SlapOS Master non-zero knowledge END # BBB: SlapOS Master non-zero knowledge END
[not-found-html]
recipe = plone.recipe.command
update-command = ${:command}
filename = notfound.html
command = ln -sf {{ software_parameter_dict['template_not_found_html'] }} ${frontend-directory:document-root}/${:filename}
[frontend-directory] [frontend-directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
document-root = ${directory:srv}/htdocs
slave-configuration = ${directory:etc}/frontend-haproxy.d/ slave-configuration = ${directory:etc}/frontend-haproxy.d/
slave-log = ${directory:log}/httpd slave-log = ${directory:log}/httpd
autocert = ${directory:srv}/autocert autocert = ${directory:srv}/autocert
......
...@@ -69,6 +69,7 @@ frontend http-frontend ...@@ -69,6 +69,7 @@ frontend http-frontend
{%- for slave_instance in frontend_slave_list -%} {%- for slave_instance in frontend_slave_list -%}
{{ frontend_entry(slave_instance, 'http', True) }} {{ frontend_entry(slave_instance, 'http', True) }}
{%- endfor %} {%- endfor %}
default_backend BACKEND_NOT_FOUND
frontend https-frontend frontend https-frontend
bind {{ configuration['local-ipv4'] }}:{{ configuration['https-port'] }} ssl crt-list {{ crt_list }} bind {{ configuration['local-ipv4'] }}:{{ configuration['https-port'] }} ssl crt-list {{ crt_list }}
...@@ -80,6 +81,7 @@ frontend https-frontend ...@@ -80,6 +81,7 @@ frontend https-frontend
{%- for slave_instance in frontend_slave_list -%} {%- for slave_instance in frontend_slave_list -%}
{{ frontend_entry(slave_instance, 'https', True) }} {{ frontend_entry(slave_instance, 'https', True) }}
{%- endfor %} {%- endfor %}
default_backend BACKEND_NOT_FOUND
# Backends # Backends
{%- for slave_instance in frontend_slave_list %} {%- for slave_instance in frontend_slave_list %}
...@@ -119,4 +121,11 @@ backend {{ slave_instance['slave_reference'] }}-{{ scheme }} ...@@ -119,4 +121,11 @@ backend {{ slave_instance['slave_reference'] }}-{{ scheme }}
{%- endif %} {# if scheme == 'http' and slave_instance['https-only'] #} {%- endif %} {# if scheme == 'http' and slave_instance['https-only'] #}
{%- endfor %} {# for (scheme, prefix) in SCHEME_PREFIX_MAPPING.items() #} {%- endfor %} {# for (scheme, prefix) in SCHEME_PREFIX_MAPPING.items() #}
{%- endfor %} {# for slave_instance in frontend_slave_list #} {%- endfor %} {# for slave_instance in frontend_slave_list #}
backend BACKEND_NOT_FOUND
{#- a bit hacky but working way to provide default CDN's 404 #}
{#- inspired by https://sleeplessbeastie.eu/2020/05/11/how-to-serve-single-file-using-haproxy/ #}
http-request set-log-level silent
errorfile 503 {{ configuration['not-found-file'] }}
{# END OF FILE #} {# END OF FILE #}
HTTP/1.0 404 Not Found
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html> <html>
<head> <head>
<title>Instance not found</title> <title>Instance not found</title>
......
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