Repository navigation
Expand file tree
/
Copy pathnginx-erudit.conf
More file actions
56 lines (48 loc) · 2.88 KB
/
Copy pathnginx-erudit.conf
File metadata and controls
56 lines (48 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Блок для существующего nginx (обратный прокси) — тестовый стенд https://erudit.23mx.ru.
# Кладётся в /etc/nginx/sites-available/erudit.conf и включается ссылкой:
# ln -s /etc/nginx/sites-available/erudit.conf /etc/nginx/sites-enabled/erudit.conf
# nginx -t && systemctl reload nginx
# (nginx читает только sites-enabled; без ссылки запросы забирает блок по умолчанию.)
# <IP контейнера> — внутренний адрес контейнера с сайтом (в git не пишем).
# Сертификат: certbot certonly --nginx -d erudit.23mx.ru (продлевается сам).
#
# Нужна переменная $connection_upgrade — она объявляется один раз на весь nginx (внутри http { }).
# На нашем прокси она уже есть (в другом сайте); если нет — раскомментировать:
# map $http_upgrade $connection_upgrade {
# default upgrade;
# '' close;
# }
server {
listen 80;
server_name erudit.23mx.ru;
# Переадресация — внутри location, а не на уровне server: при продлении сертификата
# certbot (authenticator = nginx) временно добавляет сюда свой location для проверки домена.
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name erudit.23mx.ru;
ssl_certificate /etc/letsencrypt/live/erudit.23mx.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/erudit.23mx.ru/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# Загрузка списков из Excel.
client_max_body_size 10m;
location / {
proxy_pass http://<IP контейнера>:5000;
# Blazor Server держит с браузером постоянное соединение WebSocket (SignalR).
# Без этих двух заголовков страницы откроются, но не будут реагировать на клики.
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
# Соединение живёт, пока открыта вкладка, — не обрывать его через минуту.
proxy_read_timeout 1h;
proxy_send_timeout 1h;
# Сайту нужно знать настоящий адрес, имя сайта и что снаружи был https (Program.cs → UseForwardedHeaders).
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}