1
0
mirror of https://github.com/RostislavDugin/certbot-nginx-docker.git synced 2025-07-02 22:36:51 +02:00
This commit is contained in:
Rostislav Dugin
2024-02-08 22:33:55 +03:00
commit c491004950
10 changed files with 133 additions and 0 deletions

2
.env Normal file
View File

@ -0,0 +1,2 @@
DOMAIN_URL=yourdomain.com
DOMAIN_EMAIL=youremail@mail.com

17
certbot/Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM ubuntu:22.04
EXPOSE 6000 80
ARG DOMAIN_EMAIL
ARG DOMAIN_URL
ENV DOMAIN_EMAIL=$DOMAIN_EMAIL
ENV DOMAIN_URL=$DOMAIN_URL
WORKDIR /certbot
COPY . /certbot
WORKDIR /certbot
RUN apt-get update
RUN apt-get -y install certbot
CMD ["sh", "generate-certificate.sh"]

View File

@ -0,0 +1,11 @@
#!/bin/bash
rm -rf /etc/letsencrypt/live/certfolder*
certbot certonly --standalone --email $DOMAIN_EMAIL -d $DOMAIN_URL --cert-name=certfolder --key-type rsa --agree-tos
rm -rf /etc/nginx/cert.pem
rm -rf /etc/nginx/key.pem
cp /etc/letsencrypt/live/certfolder*/fullchain.pem /etc/nginx/cert.pem
cp /etc/letsencrypt/live/certfolder*/privkey.pem /etc/nginx/key.pem

26
docker-compose.yml Normal file
View File

@ -0,0 +1,26 @@
version: "3"
services:
nginx:
image: nginx:1.23.3
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/cert.pem:/etc/cert.pem
- ./nginx/key.pem:/etc/key.pem
ports:
- "80:80"
- "443:443"
certbot:
ports:
- "6000:80"
env_file:
- .env
volumes:
- ./nginx/:/etc/nginx/
build:
context: ./certbot
dockerfile: Dockerfile
args:
DOMAIN_EMAIL: ${DOMAIN_EMAIL}
DOMAIN_URL: ${DOMAIN_URL}

9
install-docker.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
apt-get remove docker docker-engine docker.io containerd runc
apt-get install ca-certificates curl gnupg lsb-release
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

1
nginx/cert.pem Normal file
View File

@ -0,0 +1 @@
temp

1
nginx/key.pem Normal file
View File

@ -0,0 +1 @@
temp

26
nginx/nginx.conf_v1 Normal file
View File

@ -0,0 +1,26 @@
# nginx.conf
worker_processes auto;
events {
}
http {
server {
listen 80;
location / {
# здесь нужно указать локальный адрес вашего
# сайта. У меня он в Docker'e на порту 3000. У
# вас может быть адрес в духе http://127.0.0.1:ПОРТ
proxy_pass http://172.17.0.1:3000;
}
# URL certbot'a, где он будет слушать входящие
# подключения во время выдачи SSL
location /.well-known {
# адрес certbot'a в Docker Compose на Linux
proxy_pass http://172.17.0.1:6000;
}
}
}

37
nginx/nginx.conf_v2 Normal file
View File

@ -0,0 +1,37 @@
# nginx.conf
worker_processes auto;
events {
}
http {
server {
listen 80;
# делаем переадресацию с HTTP на HTTPS
location / {
return 301 https://$host$request_uri;
}
# URL certbot'a, где он будет слушать входящие
# подключения во время выдачи SSL
location /.well-known {
proxy_pass http://172.17.0.1:6000;
}
}
server {
listen 443 ssl http2;
# сертификаты мы уже примонтировали в Docker Compose
ssl_certificate /etc/cert.pem;
ssl_certificate_key /etc/key.pem;
# здесь нужно указать локальный адрес к вашему
# сайту. У меня он в Docker'e на порту 3000. У
# вам может быть адрес http://127.0.0.1:ПОРТ
location / {
proxy_pass http://172.17.0.1:3000;
}
}
}

3
readme.md Normal file
View File

@ -0,0 +1,3 @@
# Мониторинг для сайта - https://proverator.ru/
Если сайт упал или стал недоступен, уведомит в Telegram, по почте или SMS
![Проверятор](https://proverator.ru/banner.png)