You've already forked certbot-nginx-docker
mirror of
https://github.com/RostislavDugin/certbot-nginx-docker.git
synced 2025-07-02 22:36:51 +02:00
init
This commit is contained in:
2
.env
Normal file
2
.env
Normal file
@ -0,0 +1,2 @@
|
||||
DOMAIN_URL=yourdomain.com
|
||||
DOMAIN_EMAIL=youremail@mail.com
|
17
certbot/Dockerfile
Normal file
17
certbot/Dockerfile
Normal 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"]
|
11
certbot/generate-certificate.sh
Normal file
11
certbot/generate-certificate.sh
Normal 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
26
docker-compose.yml
Normal 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
9
install-docker.sh
Normal 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
1
nginx/cert.pem
Normal file
@ -0,0 +1 @@
|
||||
temp
|
1
nginx/key.pem
Normal file
1
nginx/key.pem
Normal file
@ -0,0 +1 @@
|
||||
temp
|
26
nginx/nginx.conf_v1
Normal file
26
nginx/nginx.conf_v1
Normal 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
37
nginx/nginx.conf_v2
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user