Compare commits

...

2 Commits

Author SHA1 Message Date
74f04d975c fix failpage 2024-11-17 18:51:39 +03:00
ef8ba84ebc add failsites 2024-11-17 18:46:24 +03:00
3 changed files with 59 additions and 2 deletions

View File

@ -9,6 +9,20 @@
enabled: yes enabled: yes
state: started state: started
- name: Create directory for error pages
file:
path: /var/www/errors
state: directory
owner: nginx
group: nginx
mode: '0755'
- name: Deploy custom error page
template:
src: site_down.html.j2
dest: /var/www/errors/site_down.html
mode: '0644'
- name: Deploy Proxy Configuration - name: Deploy Proxy Configuration
template: template:
src: proxy.conf.j2 src: proxy.conf.j2

View File

@ -1,6 +1,6 @@
upstream backend { upstream backend {
{% for server in upstream_servers %} {% for server in upstream_servers %}
server {{ server }} max_fails=1 fail_timeout=1s; server {{ server }} max_fails=1 fail_timeout=10s;
{% endfor %} {% endfor %}
} }
@ -12,12 +12,20 @@ server {
ssl_certificate /etc/nginx/ssl/{{ ssl_cert_file }}; ssl_certificate /etc/nginx/ssl/{{ ssl_cert_file }};
ssl_certificate_key /etc/nginx/ssl/{{ ssl_key_file }}; ssl_certificate_key /etc/nginx/ssl/{{ ssl_key_file }};
error_page 502 503 504 /site_down.html;
location = /site_down.html {
root /var/www/errors;
internal;
}
location / { location / {
proxy_pass http://backend; proxy_pass http://backend;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_intercept_errors on;
} }
location /health { location /health {

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Сайт не работает</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f8d7da;
color: #721c24;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.message {
text-align: center;
}
h1 {
font-size: 48px;
margin-bottom: 20px;
}
p {
font-size: 18px;
}
</style>
</head>
<body>
<div class="message">
<h1>Сайт не работает</h1>
<p>Просьба обратиться в техподдержку или на сервере в данный момент техработы.</p>
</div>
</body>
</html>