Skip to content

Commit

Permalink
new proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
kalta committed Dec 18, 2016
1 parent b18d0dd commit 8fb3942
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 50 deletions.
3 changes: 1 addition & 2 deletions kibana/start_service.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/bin/bash
IMAGE=netcomposer/kibana:5.0.2-1
ES="http://elastic_openresty:9200"
ES="http://elastic_proxy:9200"

docker service create \
--name kibana \
--network elastic \
-p 5601:5601 \
--env "ELASTICSEARCH_URL=$ES" \
--env "SERVER_PORT=5601" \
$IMAGE
Expand Down
3 changes: 0 additions & 3 deletions openresty/build/build.sh

This file was deleted.

29 changes: 0 additions & 29 deletions openresty/build/nginx.conf

This file was deleted.

12 changes: 0 additions & 12 deletions openresty/start_service.sh

This file was deleted.

3 changes: 3 additions & 0 deletions openresty/build/Dockerfile → proxy/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ FROM openresty/openresty:1.11.2.2-alpine

COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf
COPY profile.sh /etc/profile.d/netcomposer.sh
COPY start.sh /root/start.sh

ENTRYPOINT ["/root/start.sh"]
8 changes: 8 additions & 0 deletions proxy/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# You must set
# /usr/local/openresty/nginx/conf/elastic_passwords and
# /usr/local/openresty/nginx/conf/kibana_passwords


NAME="netcomposer/elastic-proxy:0"
docker build -t $NAME . && docker push $NAME

64 changes: 64 additions & 0 deletions proxy/build/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
daemon off;

worker_processes 1;

events {
worker_connections 1024;
}


http {
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;

upstream elastic {
server elastic:9200;
keepalive 15;
}

upstream kibana {
server kibana:5601;
keepalive 15;
}

# Internal proxy for ES
server {
listen 9200;
location / {
proxy_pass http://elastic;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}

# External proxy for ES
server {
listen 9201;
location / {
auth_basic "NetComposer Site";
auth_basic_user_file elastic_passwords;
proxy_pass http://elastic;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}

server {
listen 9202;
location / {
auth_basic "NetComposer Site";
auth_basic_user_file kibana_passwords;
proxy_pass http://kibana;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}


}
File renamed without changes.
5 changes: 5 additions & 0 deletions proxy/build/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

cp /run/secrets/elastic_passwords /usr/local/openresty/nginx/conf/elastic_passwords
cp /run/secrets/kibana_passwords /usr/local/openresty/nginx/conf/kibana_passwords
exec /usr/local/openresty/bin/openresty
File renamed without changes.
10 changes: 6 additions & 4 deletions openresty/start.sh → proxy/start.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/bin/bash
IMAGE=netcomposer/elastic-openresty:1.11.2-0
IMAGE=netcomposer/elastic-proxy:0
NAME=elastic_proxy

docker rm elastic_openresty > /dev/null 2>&1
docker rm $NAME > /dev/null 2>&1

docker run \
-ti \
--name elastic_openresty \
--name $NAME \
--network elastic \
-p 9201:9200 \
-p 9201:9201 \
-p 9202:9202 \
-v /etc/letsencrypt:/etc/letsencrypt:ro \
$IMAGE

Expand Down
16 changes: 16 additions & 0 deletions proxy/start_service.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
IMAGE=netcomposer/elastic-proxy:0

docker service create \
--constraint 'node.hostname==k1.netc.io' \
--name elastic_proxy \
--network elastic \
--secret elastic_passwords \
--secret kibana_passwords \
-p 9201:9201 \
-p 9202:9202 \
--mount type=bind,src=/etc/letsencrypt,dst=/etc/letsencrypt:ro \
$IMAGE

# --restart unless-stopped \

10 changes: 10 additions & 0 deletions set_pass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
EP=elastic_passwords
KP=kibana_passwords

docker secret rm $EP > /dev/null 2>&1
docker secret rm $KP > /dev/null 2>&1
PASS=$(openssl passwd $1)
echo "user:$PASS" | docker secret create $EP && \
echo "user:$PASS" | docker secret create $KP && \
docker service update --secret-add $EP --secret-add $KP elastic_proxy

0 comments on commit 8fb3942

Please sign in to comment.