mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
ssl сертификат1
This commit is contained in:
@@ -13,7 +13,7 @@ RUN npm run build
|
|||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
|
|
||||||
# Установка certbot
|
# Установка certbot
|
||||||
RUN apk add --no-cache certbot certbot-nginx
|
RUN apk add --no-cache certbot certbot-nginx openssl
|
||||||
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
COPY docker/frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
@@ -28,6 +28,9 @@ COPY docker/frontend/init-ssl.sh /docker-entrypoint.d/init-ssl.sh
|
|||||||
RUN chmod +x /etc/periodic/daily/ssl-renew
|
RUN chmod +x /etc/periodic/daily/ssl-renew
|
||||||
RUN chmod +x /docker-entrypoint.d/init-ssl.sh
|
RUN chmod +x /docker-entrypoint.d/init-ssl.sh
|
||||||
|
|
||||||
|
# Создаем volumes для сертификатов
|
||||||
|
VOLUME ["/etc/letsencrypt", "/var/www/certbot"]
|
||||||
|
|
||||||
EXPOSE 80 443
|
EXPOSE 80 443
|
||||||
|
|
||||||
# Запускаем crond и nginx
|
# Запускаем crond и nginx
|
||||||
|
|||||||
@@ -1,23 +1,34 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Остановка nginx
|
# Проверяем наличие сертификата
|
||||||
nginx -s stop || true
|
if [ ! -f "/etc/letsencrypt/live/itformhelp.ru/fullchain.pem" ]; then
|
||||||
|
echo "Сертификат не найден. Получаем новый..."
|
||||||
|
|
||||||
|
# Останавливаем nginx для освобождения 80 порта
|
||||||
|
nginx -s stop || true
|
||||||
|
|
||||||
|
# Ждем освобождения порта
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Получаем сертификат
|
||||||
|
certbot certonly --standalone \
|
||||||
|
--email crocoman7887@gmail.com \
|
||||||
|
--agree-tos \
|
||||||
|
--no-eff-email \
|
||||||
|
--non-interactive \
|
||||||
|
-d itformhelp.ru
|
||||||
|
|
||||||
|
# Проверяем успешность получения сертификата
|
||||||
|
if [ ! -f "/etc/letsencrypt/live/itformhelp.ru/fullchain.pem" ]; then
|
||||||
|
echo "Ошибка получения сертификата"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Сертификат успешно получен"
|
||||||
|
else
|
||||||
|
echo "Сертификат уже существует"
|
||||||
|
fi
|
||||||
|
|
||||||
# Получение сертификата
|
# Запускаем nginx с новой конфигурацией
|
||||||
certbot certonly --standalone \
|
echo "Запускаем nginx..."
|
||||||
--email crocoman7887@gmail.com \
|
|
||||||
--agree-tos \
|
|
||||||
--no-eff-email \
|
|
||||||
--staging \
|
|
||||||
-d itformhelp.ru
|
|
||||||
|
|
||||||
# После успешного получения сертификата в staging, получаем боевой сертификат
|
|
||||||
certbot certonly --standalone \
|
|
||||||
--email crocoman7887@gmail.com \
|
|
||||||
--agree-tos \
|
|
||||||
--no-eff-email \
|
|
||||||
--force-renewal \
|
|
||||||
-d itformhelp.ru
|
|
||||||
|
|
||||||
# Запуск nginx
|
|
||||||
nginx -g "daemon off;"
|
nginx -g "daemon off;"
|
||||||
@@ -1,32 +1,39 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name itformhelp.ru;
|
listen [::]:80;
|
||||||
|
server_name itformhelp.ru www.itformhelp.ru;
|
||||||
# Редирект с HTTP на HTTPS
|
|
||||||
location / {
|
|
||||||
return 301 https://$host$request_uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Для валидации Let's Encrypt
|
|
||||||
location /.well-known/acme-challenge/ {
|
location /.well-known/acme-challenge/ {
|
||||||
root /var/www/certbot;
|
root /var/www/certbot;
|
||||||
|
try_files $uri =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl http2;
|
||||||
server_name itformhelp.ru;
|
listen [::]:443 ssl http2;
|
||||||
|
server_name itformhelp.ru www.itformhelp.ru;
|
||||||
|
|
||||||
# SSL сертификаты
|
|
||||||
ssl_certificate /etc/letsencrypt/live/itformhelp.ru/fullchain.pem;
|
ssl_certificate /etc/letsencrypt/live/itformhelp.ru/fullchain.pem;
|
||||||
ssl_certificate_key /etc/letsencrypt/live/itformhelp.ru/privkey.pem;
|
ssl_certificate_key /etc/letsencrypt/live/itformhelp.ru/privkey.pem;
|
||||||
|
ssl_trusted_certificate /etc/letsencrypt/live/itformhelp.ru/chain.pem;
|
||||||
|
|
||||||
# Оптимизация SSL
|
# Улучшенные настройки SSL
|
||||||
ssl_session_cache shared:SSL:10m;
|
ssl_session_timeout 1d;
|
||||||
ssl_session_timeout 10m;
|
ssl_session_cache shared:SSL:50m;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
|
||||||
|
# Современные настройки безопасности
|
||||||
ssl_protocols TLSv1.2 TLSv1.3;
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
ssl_prefer_server_ciphers off;
|
|
||||||
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
|
||||||
|
ssl_prefer_server_ciphers off;
|
||||||
|
|
||||||
|
# HSTS (раскомментируйте после успешного тестирования SSL)
|
||||||
|
# add_header Strict-Transport-Security "max-age=63072000" always;
|
||||||
|
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|||||||
Reference in New Issue
Block a user