Files
pushkinohistory-ru-v2/nginx/pushkinohistory.ru.conf

101 lines
4.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# pushkinohistory.ru — Vite+React (v2)
# Container: pushkinohistory-ru-v2 on 127.0.0.1:4146
# v2 cutover: 2026-05-21 (старый WP на :4143 оставлен в /opt/docker/sites/pushkinohistory-ru как backup)
# 301-редиректы со старых URL-encoded WP slugs (cyrillic) на новые транслитерированные.
# nginx уже декодирует URI до cyrillic'а, поэтому в ключах map'а — кириллица в UTF-8.
map $request_uri $legacy_redirect {
default "";
~^/добро-пожаловать/?$ /dobro-pozhalovat/;
~^/фото/?$ /foto/;
~^/сегодня-ночью-россияне-увидят-первое-суперлуние-года-волчью-луну/?$ /segodnya-nochyu-rossiyane-uvidyat-pervoe/;
~^/первые-20-градусные-морозы/?$ /pervye-20-gradusnye-morozy/;
}
server {
listen 80;
listen [::]:80;
server_name pushkinohistory.ru www.pushkinohistory.ru;
include /etc/nginx/templates/letsencrypt.conf;
location / { return 301 https://pushkinohistory.ru$request_uri; }
}
server {
listen 443 ssl;
listen 443 quic;
listen [::]:443 ssl;
listen [::]:443 quic;
http2 on;
server_name www.pushkinohistory.ru;
ssl_certificate /etc/letsencrypt/live/pushkinohistory.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/pushkinohistory.ru/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/pushkinohistory.ru/chain.pem;
include /etc/nginx/templates/ssl.conf;
include /etc/nginx/templates/security-headers.conf;
include /etc/nginx/templates/rugov-block.conf;
return 301 https://pushkinohistory.ru$request_uri;
}
server {
listen 443 ssl;
listen 443 quic;
listen [::]:443 ssl;
listen [::]:443 quic;
http2 on;
server_name pushkinohistory.ru;
ssl_certificate /etc/letsencrypt/live/pushkinohistory.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/pushkinohistory.ru/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/pushkinohistory.ru/chain.pem;
include /etc/nginx/templates/ssl.conf;
include /etc/nginx/templates/security-headers.conf;
include /etc/nginx/templates/rugov-block.conf;
include /etc/nginx/templates/letsencrypt.conf;
access_log /var/log/nginx/access/pushkinohistory.ru.access.log;
error_log /var/log/nginx/errors/pushkinohistory.ru.error.log warn;
client_max_body_size 4M;
# 301-редиректы с легаси WP-slugs на новые транслитерированные пути
if ($legacy_redirect != "") {
return 301 $legacy_redirect;
}
# WP-эндпоинты — больше не существуют, отдаём 410 Gone (помогает поисковикам пометить как удалённые)
location ~* ^/(wp-admin|wp-login\.php|wp-content|wp-includes|xmlrpc\.php|wp-cron\.php|wp-config\.php|readme\.html)$ {
return 410;
}
# RSS-фид (статичный файл, отдаётся из dist)
location = /feed/ {
proxy_pass http://127.0.0.1:4146;
include /etc/nginx/templates/proxy.conf;
add_header Content-Type "application/rss+xml; charset=utf-8" always;
add_header Cache-Control "public, max-age=600" always;
}
# Агрегатор новостей: апдейтится по cron, кешируем коротко
location = /api/news.json {
proxy_pass http://127.0.0.1:4146;
include /etc/nginx/templates/proxy.conf;
add_header Cache-Control "public, max-age=120" always;
}
# Картинки/статические ассеты — кешируем подольше
location ~* ^/(uploads|assets)/ {
proxy_pass http://127.0.0.1:4146;
include /etc/nginx/templates/proxy.conf;
add_header Cache-Control "public, max-age=604800, immutable" always;
proxy_cache_valid 200 7d;
}
location / {
proxy_pass http://127.0.0.1:4146;
include /etc/nginx/templates/proxy.conf;
proxy_read_timeout 30s;
}
}