Skip to content

Commit

Permalink
add caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
devincowan committed Mar 1, 2023
1 parent c1eb179 commit cb65ee6
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
METRICS_LOGS_DIR='/var/log'
METRICS_LOGFILE_MATCH='*log*'
EXPOSTED_PORT=8090
KIBANA_EXPOSED_PORT=5601
ELASTIC_EXPOSED_PORT=9200
CADDY_EXPOSED_PORT=8080
CADDY_PUBLIC_DIR='./caddy/dist/'
ELASTIC_VERSION=8.5.2

## Passwords for stack users
Expand Down
26 changes: 26 additions & 0 deletions caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

:80 {
# Set this path to your site's directory.
root * /usr/share/caddy

# Enable the static file server.
file_server browse

# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080

# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
1 change: 1 addition & 0 deletions caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM caddy:2.6
2 changes: 2 additions & 0 deletions caddy/dist/example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is just an example file to be statically served by caddy
if you want to see other files, you should change CADDY_PUBLIC_DIR in your .env file
32 changes: 26 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ services:
- ./logstash/config/hs-template.json:/etc/logstash/hs-template.json:ro,Z
# Easy viewing of logs on host for debug
# - ./logs/logstash:${METRICS_LOGS_DIR}/logstash/
ports:
- 5044:5044
# ports:
# - 5044:5044
# - 50000:50000/tcp
# - 50000:50000/udp
# - 9600:9600
Expand Down Expand Up @@ -108,19 +108,37 @@ services:
context: nginx/
restart: unless-stopped
ports:
- "${EXPOSTED_PORT}:80"
- "8080:8080"
- "${ELASTIC_EXPOSED_PORT}:${ELASTIC_EXPOSED_PORT}"
- "${KIBANA_EXPOSED_PORT}:${KIBANA_EXPOSED_PORT}"
- "${CADDY_EXPOSED_PORT}:${CADDY_EXPOSED_PORT}"
volumes:
- ./nginx/conf.d_templates:/etc/nginx/templates
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro,Z
networks:
- elk
- caddy
environment:
NGINX_ENVSUBST_TEMPLATE_DIR: /etc/nginx/templates
NGINX_ENVSUBST_TEMPLATE_SUFFIX: ".conf"
METRICS_HOSTNAME: usagemetrics.hydroshare.org
depends_on:
- kibana
CADDY_EXPOSED_PORT: ${CADDY_EXPOSED_PORT}
ELASTIC_EXPOSED_PORT: ${ELASTIC_EXPOSED_PORT}
KIBANA_EXPOSED_PORT: ${KIBANA_EXPOSED_PORT}

caddy:
build:
context: caddy/
image: caddy:2.6
restart: unless-stopped
# ports:
# - "80:80"
# - "443:443"
# - "443:443/udp"
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
- ${CADDY_PUBLIC_DIR}:/usr/share/caddy/
networks:
- caddy

filebeat:
depends_on:
Expand All @@ -144,6 +162,8 @@ services:
networks:
elk:
driver: bridge
caddy:
driver: bridge

volumes:
setup:
Expand Down
2 changes: 1 addition & 1 deletion filebeat/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ filebeat.inputs:
- "${METRICS_LOGS_DIR:/var/log}/${METRICS_LOGFILE_MATCH:*log*}"

output.logstash:
hosts: ["logstash:5044"]
hosts: ["nginx:5044"]
username: 'elastic'
password: '${ELASTIC_PASSWORD}'
13 changes: 13 additions & 0 deletions nginx/conf.d_templates/caddy.conf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
upstream docker-caddy {
server caddy:80;
}

server {
listen ${CADDY_EXPOSED_PORT};
server_name ${METRICS_HOSTNAME};
access_log /var/log/nginx/caddy-public.log;

location / {
proxy_pass http://docker-caddy;
}
}
2 changes: 1 addition & 1 deletion nginx/conf.d_templates/es.conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ upstream docker-elasticsearch {
}

server {
listen 8080;
listen ${ELASTIC_EXPOSED_PORT};
server_name ${METRICS_HOSTNAME};

# # Deny Nodes Shutdown API
Expand Down
2 changes: 1 addition & 1 deletion nginx/conf.d_templates/kibana.conf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ upstream docker-kibana {
}

server {
listen 80;
listen ${KIBANA_EXPOSED_PORT};
server_name ${METRICS_HOSTNAME};
access_log /var/log/nginx/kibana-public.log;

Expand Down

0 comments on commit cb65ee6

Please sign in to comment.