nginx: vhost для v2 (порт 4146, 301-карта для legacy WP cyrillic slugs) + CLAUDE.md проекта

This commit is contained in:
striker
2026-05-21 01:26:23 +03:00
parent 76cdeb8b48
commit a0219ee8f3
2 changed files with 191 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
# 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;
}
}