Compare commits
2 Commits
54582d0f1d
...
74f04d975c
Author | SHA1 | Date | |
---|---|---|---|
74f04d975c | |||
ef8ba84ebc |
@ -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
|
||||||
@ -17,4 +31,4 @@
|
|||||||
- name: Reload Nginx
|
- name: Reload Nginx
|
||||||
systemd:
|
systemd:
|
||||||
name: nginx
|
name: nginx
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
@ -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 {
|
||||||
|
35
ansible/roles/nginx_proxy/templates/site_down.html.j2
Normal file
35
ansible/roles/nginx_proxy/templates/site_down.html.j2
Normal 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>
|
Loading…
Reference in New Issue
Block a user