Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgarde committed Apr 4, 2024
0 parents commit 20cad12
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
push:
branches:
- '*'
tags-ignore:
- '*'
paths-ignore:
- 'bumpver.toml'

jobs:
build:
name: build, lint, and test hysds-integration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# -- Build --
- name: Build
run: docker build -t "ngap-dit-proxy:$(cat version.txt)" .
- name: Tag as latest
if: github.ref == 'refs/heads/main'
run: docker tag ghcr.io/podaac/ngap-dit-proxy:$(cat version.txt) ghcr.io/podaac/ngap-dit-proxy:latest
- name: Publish Docker images
run: docker image push -a ghcr.io/podaac/ngap-dit-proxy
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vscode/
.DS_Store
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM nginx:mainline-alpine-slim

RUN set -x \
&& apk update \
&& apk add aws-cli cronie openssl

COPY --chmod=770 files/renew-cert.sh files/start-cron.sh /docker-entrypoint.d/
RUN ln -s /docker-entrypoint.d/renew-cert.sh /etc/periodic/daily/renew-cert.sh

COPY files/ssl-proxy.conf.template /etc/nginx/templates/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# ngap-dit-proxy

An Nginx-based reverse proxy for implementing HTTPS with auto-renewing
certificates provided by the NGAP private CA

## Environment variables

To run this container, you must set the following environment variables:

| Variable | Description |
|----------------------|--------------------------------------------------|
| HOSTNAME | The hostname of the certificate generated |
| NGAP_CERTIFICATE_ARN | The ARN of the certificate to use for this proxy |
| APP_PORT | The local HTTP port to reverse proxy as HTTPS |
15 changes: 15 additions & 0 deletions files/renew-cert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -xe
umask 177

openssl rand --base64 16 | tr -d '\n' > /etc/nginx/passphrase.txt
aws acm export-certificate \
--certificate-arn $NGAP_CERTIFICATE_ARN \
--passphrase fileb://etc/nginx/passphrase.txt \
--query "[Certificate,CertificateChain,PrivateKey]" \
--output text | sed -e "s/^\s*//g" > /etc/nginx/certificate.pem

if [ -f /var/run/nginx.pid ]; then
nginx -s reload
fi
16 changes: 16 additions & 0 deletions files/ssl-proxy.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server {
listen 443 ssl;
listen [::]:443 ssl;

server_name ${HOSTNAME};

ssl_password_file /etc/nginx/passphrase.txt;
ssl_certificate /etc/nginx/certificate.pem;
ssl_certificate_key /etc/nginx/certificate.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;

location / {
proxy_pass http://localhost:${APP_PORT};
}
}
2 changes: 2 additions & 0 deletions files/start-cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
crond
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0

0 comments on commit 20cad12

Please sign in to comment.