Skip to content

Commit 32ca2a9

Browse files
committed
Add config for auto install certificate
1 parent 18d496e commit 32ca2a9

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ signupEnabled=false
1414
dockerHttpPort=80
1515
dockerHttpsPort=443
1616
useMailAlerts=true
17+
autoInstallCertificate=true
1718
domain=example.ezxss.com
1819

1920
# ezProxy settings

Dockerfile

+28-27
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,36 @@ RUN apt-get update && \
1515

1616
RUN a2enmod ssl
1717

18-
RUN certbot certonly --non-interactive --agree-tos --email webmaster@${DOMAIN} --webroot --webroot-path=/data/letsencrypt -d ${DOMAIN}
18+
ARG INSTALL_CERTIFICATE
1919

20-
RUN echo "<VirtualHost *:80>\n\
21-
ServerAdmin webmaster@${DOMAIN}\n\
22-
DocumentRoot /var/www/html\n\
23-
Alias /.well-known/acme-challenge /var/www/letsencrypt/data/.well-known/acme-challenge
24-
25-
</Directory>\n\
26-
</VirtualHost>" > /etc/apache2/sites-available/000-no-ssl-default.conf
27-
28-
RUN a2ensite no-ssl-default
29-
30-
RUN echo "<VirtualHost *:443>\n\
31-
ServerAdmin webmaster@${DOMAIN}\n\
32-
DocumentRoot /var/www/html\n\
33-
SSLEngine on\n\
34-
SSLCertificateFile /etc/letsencrypt/live/${DOMAIN}/fullchain.pem\n\
35-
SSLCertificateKeyFile /etc/letsencrypt/live/${DOMAIN}/privkey.pem\n\
36-
ErrorLog \${APACHE_LOG_DIR}/error.log\n\
37-
CustomLog \${APACHE_LOG_DIR}/access.log combined\n\
38-
<Directory /var/www/html>\n\
39-
Options Indexes FollowSymLinks\n\
40-
AllowOverride All\n\
41-
Require all granted\n\
42-
</Directory>\n\
43-
</VirtualHost>" > /etc/apache2/sites-available/default-ssl.conf
20+
RUN if [ "$INSTALL_CERTIFICATE" = "true" ]; then \
21+
certbot certonly --non-interactive --agree-tos --email webmaster@${DOMAIN} --webroot --webroot-path=/data/letsencrypt -d ${DOMAIN}; \
22+
fi
4423

45-
RUN a2ensite default-ssl
24+
RUN if [ "$INSTALL_CERTIFICATE" = "true" ]; then \
25+
echo "<VirtualHost *:80>\n\
26+
ServerAdmin webmaster@${DOMAIN}\n\
27+
DocumentRoot /var/www/html\n\
28+
Alias /.well-known/acme-challenge /var/www/letsencrypt/data/.well-known/acme-challenge\n\
29+
</Directory>\n\
30+
</VirtualHost>" > /etc/apache2/sites-available/000-no-ssl-default.conf && \
31+
a2ensite no-ssl-default && \
32+
echo "<VirtualHost *:443>\n\
33+
ServerAdmin webmaster@${DOMAIN}\n\
34+
DocumentRoot /var/www/html\n\
35+
SSLEngine on\n\
36+
SSLCertificateFile /etc/letsencrypt/live/${DOMAIN}/fullchain.pem\n\
37+
SSLCertificateKeyFile /etc/letsencrypt/live/${DOMAIN}/privkey.pem\n\
38+
ErrorLog \${APACHE_LOG_DIR}/error.log\n\
39+
CustomLog \${APACHE_LOG_DIR}/access.log combined\n\
40+
<Directory /var/www/html>\n\
41+
Options Indexes FollowSymLinks\n\
42+
AllowOverride All\n\
43+
Require all granted\n\
44+
</Directory>\n\
45+
</VirtualHost>" > /etc/apache2/sites-available/default-ssl.conf && \
46+
a2ensite default-ssl; \
47+
fi
4648

4749
COPY . /var/www/html
4850

@@ -64,4 +66,3 @@ RUN chmod 777 /var/www/html/assets/img
6466

6567
ENTRYPOINT ["docker-php-entrypoint"]
6668
CMD ["apache2-foreground"]
67-

docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
dockerfile: ./Dockerfile
1919
args:
2020
- USE_MAIL_ALERTS=${useMailAlerts}
21+
- INSTALL_CERTIFICATE=${autoInstallCertificate}
2122
- DOMAIN=${domain}
2223
ports:
2324
- "${dockerHttpPort:-80}:80"

0 commit comments

Comments
 (0)