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
|
||||
|
||||
# Установка 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 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 /docker-entrypoint.d/init-ssl.sh
|
||||
|
||||
# Создаем volumes для сертификатов
|
||||
VOLUME ["/etc/letsencrypt", "/var/www/certbot"]
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
# Запускаем crond и nginx
|
||||
|
@@ -1,23 +1,34 @@
|
||||
#!/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
|
||||
|
||||
# Получение сертификата
|
||||
certbot certonly --standalone \
|
||||
--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 с новой конфигурацией
|
||||
echo "Запускаем nginx..."
|
||||
nginx -g "daemon off;"
|
@@ -1,32 +1,39 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name itformhelp.ru;
|
||||
|
||||
# Редирект с HTTP на HTTPS
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
# Для валидации Let's Encrypt
|
||||
listen [::]:80;
|
||||
server_name itformhelp.ru www.itformhelp.ru;
|
||||
|
||||
location /.well-known/acme-challenge/ {
|
||||
root /var/www/certbot;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name itformhelp.ru;
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name itformhelp.ru www.itformhelp.ru;
|
||||
|
||||
# SSL сертификаты
|
||||
ssl_certificate /etc/letsencrypt/live/itformhelp.ru/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/itformhelp.ru/privkey.pem;
|
||||
ssl_trusted_certificate /etc/letsencrypt/live/itformhelp.ru/chain.pem;
|
||||
|
||||
# Оптимизация SSL
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
# Улучшенные настройки SSL
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:SSL:50m;
|
||||
ssl_session_tickets off;
|
||||
|
||||
# Современные настройки безопасности
|
||||
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_prefer_server_ciphers off;
|
||||
|
||||
# HSTS (раскомментируйте после успешного тестирования SSL)
|
||||
# add_header Strict-Transport-Security "max-age=63072000" always;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
Reference in New Issue
Block a user