Skip to content

Commit 3756942

Browse files
committed
Initial commit
0 parents  commit 3756942

File tree

5 files changed

+138
-0
lines changed

5 files changed

+138
-0
lines changed

.gitignore

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Project files
2+
.env
3+
.bitrise*.yml
4+
bitrise.yml
5+
6+
# Docker project generated files to ignore
7+
# if you want to ignore files created by your editor/tools,
8+
# please consider a global .gitignore https://help.github.com/articles/ignoring-files
9+
.vagrant*
10+
bin
11+
docker/docker
12+
.*.swp
13+
a.out
14+
*.orig
15+
build_src
16+
.flymake*
17+
.idea
18+
.DS_Store
19+
docs/_build
20+
docs/_static
21+
docs/_templates
22+
.gopath/
23+
.dotcloud
24+
*.test
25+
bundles/
26+
.hg/
27+
.git/
28+
vendor/pkg/
29+
pyenv
30+
Vagrantfile

LICENSE

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2022 Igor Castañeda Ferreira
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

certificate.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
HOST=""
4+
CONTACT_EMAIL=""
5+
6+
while [ -n "$1" ]; do
7+
case "$1" in
8+
--host | -h) HOST="$2" && shift;;
9+
--email | -e) CONTACT_EMAIL="$2" && shift;;
10+
esac
11+
shift
12+
done
13+
14+
if [ -z "${HOST}" ]; then
15+
echo "Please, provide a host to be used with the '--host' argument. Example:"
16+
echo "$ ./certificate.sh --host website.domain.com --email [email protected]"
17+
exit 1
18+
fi
19+
20+
if [ -z "${CONTACT_EMAIL}" ]; then
21+
echo "Please, provide a host to be used with the '--email' argument. Example:"
22+
echo "$ ./certificate.sh --host website.domain.com --email [email protected]"
23+
exit 1
24+
fi
25+
26+
docker run \
27+
-v letsencrypt:/etc/letsencrypt \
28+
-v acme-challenge:/var/www/challenge/.well-known/acme-challenge \
29+
--name certbot \
30+
"certbot/certbot" \
31+
certonly --webroot -w /var/www/challenge -d "${HOST}" -m "${CONTACT_EMAIL}" --agree-tos

docker-compose.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: '3'
2+
services:
3+
proxy:
4+
restart: unless-stopped
5+
image: nginx:latest
6+
ports:
7+
- 80:$PROXY_HTTP_PORT/tcp
8+
- 443:$PROXY_HTTPS_PORT/tcp
9+
volumes:
10+
- ./templates:/etc/nginx/templates
11+
- letsencrypt:/etc/letsencrypt
12+
- acme-challenge:/var/www/challenge/.well-known/acme-challenge
13+
env_file:
14+
- ./.env
15+
volumes:
16+
letsencrypt: {}
17+
acme-challenge: {}

templates/proxy.conf.template

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
server {
2+
listen ${PROXY_HTTPS_PORT} ssl default_server;
3+
server_name ${PROXY_HOST};
4+
5+
gzip on;
6+
gzip_comp_level 2;
7+
gzip_min_length 1024;
8+
gzip_vary on;
9+
gzip_proxied expired no-cache no-store private auth;
10+
gzip_types application/x-javascript application/javascript application/xml application/json text/xml text/css text$
11+
12+
client_body_timeout 12;
13+
client_header_timeout 12;
14+
reset_timedout_connection on;
15+
proxy_connect_timeout 600;
16+
proxy_send_timeout 600;
17+
proxy_read_timeout 600;
18+
send_timeout 600;
19+
server_tokens off;
20+
client_max_body_size 50m;
21+
22+
expires 1y;
23+
access_log off;
24+
log_not_found off;
25+
root /var/www/public/content/default;
26+
ssl_certificate /etc/letsencrypt/live/${PROXY_HOST}/fullchain.pem;
27+
ssl_certificate_key /etc/letsencrypt/live/${PROXY_HOST}/privkey.pem;
28+
29+
location / {
30+
proxy_pass http://${PROXY_REDIRECT_HOST}:${PROXY_REDIRECT_PORT};
31+
proxy_http_version 1.1;
32+
proxy_set_header X-Forwarded-Host $host;
33+
proxy_set_header X-Forwarded-Server $host;
34+
proxy_set_header X-Real-IP $remote_addr;
35+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
36+
proxy_set_header X-Forwarded-Proto $scheme;
37+
proxy_set_header Host $http_host;
38+
proxy_set_header Upgrade $http_upgrade;
39+
proxy_set_header Connection "Upgrade";
40+
proxy_pass_request_headers on;
41+
}
42+
}
43+
44+
server {
45+
listen ${PROXY_HTTP_PORT};
46+
listen [::]:${PROXY_HTTP_PORT};
47+
server_name ${PROXY_HOST};
48+
49+
location ~ /.well-known/acme-challenge {
50+
allow all;
51+
root /var/www/html;
52+
}
53+
}

0 commit comments

Comments
 (0)