Skip to content
This repository was archived by the owner on Jan 21, 2023. It is now read-only.

Commit 34f80ac

Browse files
committed
add all the new ssl awesomeness to version 4.6
1 parent 34a3bad commit 34f80ac

File tree

7 files changed

+74
-23
lines changed

7 files changed

+74
-23
lines changed

4.6/Dockerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ENV ELASTIC 2.4.1
2525
ENV LOGSTASH 2.4.0
2626
ENV KIBANA 4.6.2
2727

28-
RUN apk-install libzmq bash nodejs supervisor nginx apache2-utils
28+
RUN apk-install libzmq bash nodejs supervisor nginx apache2-utils openssl
2929
RUN mkdir -p /usr/local/lib \
3030
&& ln -s /usr/lib/*/libzmq.so.3 /usr/local/lib/libzmq.so
3131
RUN apk-install -t .build-deps wget ca-certificates \
@@ -68,6 +68,8 @@ RUN apk-install -t .build-deps wget ca-certificates \
6868
&& apline_node='NODE="/usr/bin/node"' \
6969
&& sed -i "s|$bundled|$apline_node|g" /usr/share/kibana/bin/kibana \
7070
&& rm -rf /usr/share/kibana/node \
71+
&& echo "Make Ngins SSL directory..." \
72+
&& mkdir -p /etc/nginx/ssl \
7173
&& echo "Create elstack user..." \
7274
&& adduser -DH -s /sbin/nologin elstack \
7375
&& chown -R elstack:elstack /usr/share/elasticsearch \
@@ -84,23 +86,28 @@ ENV PATH /usr/share/kibana/bin:$PATH
8486
# Add custom elasticsearch config
8587
COPY config/elastic /usr/share/elasticsearch/config
8688
COPY config/elastic/logrotate /etc/logrotate.d/elasticsearch
89+
8790
# Add custom logstash config
8891
COPY config/logstash/conf.d/ /etc/logstash/conf.d/
8992
COPY config/logstash/patterns/ /opt/logstash/patterns/
9093
COPY config/logstash/logstash.yml /etc/logstash/
94+
9195
# necessary for 5.0+ (overriden via "--path.settings", ignored by < 5.0)
9296
ENV LS_SETTINGS_DIR /etc/logstash
97+
9398
# Add custom nginx config
9499
COPY config/nginx/nginx.conf /etc/nginx/nginx.conf
95100
COPY config/nginx/kibana.conf /etc/nginx/conf.d/
96-
COPY config/nginx/htpasswd /etc/nginx/htpasswd.users
101+
COPY config/nginx/ssl.kibana.conf /etc/nginx/conf.d/
102+
97103
# Add custom supervisor config
98104
COPY config/supervisord/supervisord.conf /etc/supervisor/
99105

100106
# Add entrypoints
101107
COPY entrypoints/elastic-entrypoint.sh /
102108
COPY entrypoints/logstash-entrypoint.sh /
103109
COPY entrypoints/kibana-entrypoint.sh /
110+
COPY entrypoints/nginx-entrypoint.sh /
104111

105112
VOLUME ["/usr/share/elasticsearch/data"]
106113
VOLUME ["/etc/logstash/conf.d"]

4.6/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ dev:
77
docker run --rm $(NAME):dev $(DEV_RUN_OPTS)
88

99
build:
10-
docker build -t $(NAME):$(VERSION) .; sleep 3;
11-
sed -i.bu 's/docker image-.*-blue/docker image-$(shell docker images --format "{{.Size}}" $(NAME):$(VERSION))-blue/g' ../README.md
10+
docker build -t blacktop/$(NAME):$(VERSION) .
11+
12+
size:
13+
sed -i.bu 's/docker image-.*-blue/docker image-$(shell docker images --format "{{.Size}}" blacktop/$(NAME):$(VERSION))-blue/g' ../README.md
1214

1315
release:
1416
rm -rf release && mkdir release

4.6/config/nginx/kibana.conf

100644100755
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ server {
33

44
server_name elstack;
55

6-
auth_basic "Restricted Access";
7-
auth_basic_user_file /etc/nginx/htpasswd.users;
8-
96
location / {
107
proxy_pass http://127.0.0.1:5601;
118
proxy_http_version 1.1;

4.6/config/nginx/ssl.kibana.conf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
server {
2+
listen [::]:80 default_server;
3+
listen 80 default_server;
4+
5+
server_name _;
6+
7+
return 301 https://$host$request_uri;
8+
}
9+
10+
server {
11+
listen [::]:443 ssl http2;
12+
listen 443 ssl http2;
13+
14+
server_name _;
15+
16+
auth_basic "Restricted Access";
17+
auth_basic_user_file /etc/nginx/htpasswd.users;
18+
19+
ssl on;
20+
ssl_certificate /etc/nginx/ssl/kibana.crt;
21+
ssl_certificate_key /etc/nginx/ssl/kibana.key;
22+
23+
location / {
24+
proxy_pass http://127.0.0.1:5601;
25+
proxy_http_version 1.1;
26+
proxy_set_header Upgrade $http_upgrade;
27+
proxy_set_header Connection 'upgrade';
28+
proxy_set_header Host $host;
29+
proxy_cache_bypass $http_upgrade;
30+
}
31+
}

4.6/config/supervisord/supervisord.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ autostart=true
77
autorestart=true
88
stdout_logfile=/var/log/logstash.stdout.log
99
stderr_logfile=/var/log/logstash.stderr.log
10-
priority=2
10+
# priority=2
1111

1212
[program:elasticsearch]
1313
command = /elastic-entrypoint.sh elasticsearch
1414
autostart=true
1515
autorestart=true
1616
stdout_logfile=/var/log/elasticsearch.stdout.log
1717
stderr_logfile=/var/log/elasticsearch.stderr.log
18-
priority=1
18+
# priority=1
1919

2020
[program:kibana]
2121
command = /kibana-entrypoint.sh kibana
@@ -26,9 +26,9 @@ stdout_logfile=/var/log/kibana.stdout.log
2626
stderr_logfile=/var/log/kibana.stderr.log
2727

2828
[program:nginx]
29-
command = nginx -g 'daemon off;'
29+
command = /nginx-entrypoint.sh
3030
autostart=true
3131
autorestart=true
3232
stdout_logfile=/var/log/nginx.stdout.log
3333
stderr_logfile=/var/log/nginx.stderr.log
34-
priority=4
34+
# priority=4

4.6/entrypoints/nginx-entrypoint.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
set -e
3+
: ${ELSK_USER:="admin"}
4+
: ${ELSK_PASS:="admin"}
5+
: ${ELSK_DOMAIN:="localhost"}
46

5-
# Add logstash as command if needed
6-
if [ "${1:0:1}" = '-' ]; then
7-
set -- nginx "$@"
8-
fi
7+
if [ -z "$SSL" ]; then
8+
echo ">> using non-ssl nginx conf"
9+
rm /etc/nginx/conf.d/ssl.kibana.conf
10+
exec nginx -g 'daemon off;'
11+
else
12+
echo ">> generating basic auth"
13+
htpasswd -b -c /etc/nginx/htpasswd.users "$ELSK_USER" "$ELSK_PASS"
914

10-
# Run as user "nginx" if the command is "nginx"
11-
if [ "$1" = 'nginx' ]; then
15+
if [ ! -e "/etc/nginx/ssl/*.key" ]; then
16+
echo ">> generating self signed cert"
17+
openssl req -x509 -newkey rsa:4086 \
18+
-subj "/C=XX/ST=XXXX/L=XXXX/O=XXXX/CN=$ELSK_DOMAIN" \
19+
-keyout "/etc/nginx/ssl/kibana.key" \
20+
-out "/etc/nginx/ssl/kibana.crt" \
21+
-days 3650 -nodes -sha256
22+
fi
1223

13-
set -- gosu elstack tini -- "$@"
24+
echo ">> using ssl nginx conf"
25+
rm /etc/nginx/conf.d/kibana.conf
26+
exec nginx -g 'daemon off;'
1427
fi
15-
16-
exec "$@"

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Same as v5.0
1717

1818
### Added
1919

20-
- Nginx entrypoint to pass USER/PASS in as env vars
20+
- Nginx entry-point to pass USER/PASS in as env vars
2121
- SSL (auto-create certs if not found)
2222
- tini/gosu to all the things
2323
- geoip/user-agent plugin
@@ -36,6 +36,9 @@ Same as v5.0
3636

3737
### Added
3838

39+
- Nginx entry-point to pass USER/PASS in as env vars
40+
- SSL (auto-create certs if not found)
41+
3942
### Removed
4043

4144
### Changed

0 commit comments

Comments
 (0)