diff --git a/defaults/main/template.yml b/defaults/main/template.yml index 8d75b67..cc0e31e 100644 --- a/defaults/main/template.yml +++ b/defaults/main/template.yml @@ -77,6 +77,7 @@ nginx_http_template: opts: [] # Listen opts like http2 which will be added (ssl is automatically added if you specify 'ssl:'). server_name: localhost include_files: [] + http_error_pages: {} error_page: /usr/share/nginx/html access_log: - name: main diff --git a/molecule/common/playbook_template.yml b/molecule/common/playbook_template.yml index ba33cbf..29e77eb 100644 --- a/molecule/common/playbook_template.yml +++ b/molecule/common/playbook_template.yml @@ -77,6 +77,8 @@ opts: - default_server server_name: localhost + http_error_pages: + 404: /404.html error_page: /usr/share/nginx/html client_max_body_size: 512k proxy_hide_headers: diff --git a/templates/http/default.conf.j2 b/templates/http/default.conf.j2 index 6000a17..ac4dc85 100644 --- a/templates/http/default.conf.j2 +++ b/templates/http/default.conf.j2 @@ -475,6 +475,12 @@ server { } {% endfor %} {% endif %} +{% if item.value.servers[server].http_error_pages is defined %} + # redirect server error pages +{% for error_code in item.value.servers[server].http_error_pages %} + error_page {{ error_code }} {{ item.value.servers[server].http_error_pages[error_code] }}; +{% endfor %} +{% endif %} {% if item.value.servers[server].error_page is defined %} # redirect server error pages to the static page /50x.html #