-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create proxy with HTTPS for UCCSER websites
- Loading branch information
1 parent
66cbab1
commit 3ac0188
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
certs/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,41 @@ | ||
# uccser-development-proxy | ||
Proxy for working on UCCSER websites | ||
# UCCSER Development Proxy | ||
|
||
This proxy is used when working on the following UCCSER websites: | ||
|
||
- [CS Unplugged](https://github.com/uccser/cs-unplugged) | ||
- [CS Field Guide](https://github.com/uccser/cs-field-guide) | ||
- [codeWOF](https://github.com/uccser/codewof) | ||
- [DTHM for Kaiako](https://github.com/uccser/dthm4kaiako) | ||
|
||
This proxy allows multiple systems to run on your development environment simultaneously. | ||
|
||
# Setup | ||
|
||
You will need to have the following tools installed to run this proxy: | ||
|
||
- Docker | ||
- Docker Compose | ||
- [mkcert](https://github.com/FiloSottile/mkcert) | ||
|
||
Once these tools have been installed, then run `./create-certs.sh`. | ||
The script will create SSL certificates for all our websites. | ||
The script will finish with telling you when the certificates expire, where you will be required to rerun this setup. | ||
|
||
# Usage | ||
|
||
To run the proxy, run `docker-compose up -d` in this project directory. | ||
Docker will run the proxy in the background. | ||
|
||
You can view the dashboard of the proxy by opening a browser and going to `proxy.localhost` in your preferred web browser. | ||
|
||
To view logs of the proxy, run `docker-compose logs -f traefik`. | ||
|
||
Do shutdown the proxy, run `docker-compose down`. | ||
If you get a error when running this command, saying `ERROR: error while removing network: network uccser-development-proxy`, then one of our website systems is likely still running. | ||
The proxy will be shutdown, but the network will remain active. | ||
If you wish to remove the network, you will need to end all UCCSER website systems first. | ||
|
||
# Notes | ||
|
||
The proxy binds to ports 80 and 443. | ||
If you are trying to run other systems that wish to bind to these ports, you will need to shutdown the proxy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
mkcert -install | ||
mkdir certs | ||
mkcert -key-file certs/key.pem -cert-file certs/cert.pem proxy.localhost cs-unplugged.localhost *.cs-unplugged.localhost cs-field-guide.localhost *.cs-field-guide.localhost codewof.localhost *.codewof.localhost dthm4kaiako.localhost *.dthm4kaiako.localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: "3.8" | ||
|
||
services: | ||
traefik: | ||
image: traefik:v2.4.13 | ||
container_name: uccser-development-proxy | ||
ports: | ||
# HTTP/HTTPS ports | ||
- "80:80" | ||
- "443:443" | ||
environment: | ||
- TZ=Pacific/Auckland | ||
volumes: | ||
# So that Traefik can listen to the Docker events | ||
- /var/run/docker.sock:/var/run/docker.sock:ro | ||
# Map certificates into the container | ||
- ./certs:/etc/traefik/:z | ||
# Map static config into the container | ||
- ./traefik.yml:/etc/traefik/traefik.yml:ro | ||
networks: | ||
- uccser-development-proxy | ||
labels: | ||
# General labels | ||
- "traefik.enable=true" | ||
- "traefik.http.services.traefik.loadbalancer.server.port=8080" | ||
# HTTPS | ||
- "traefik.http.routers.traefik.entryPoints=web-secure" | ||
- "traefik.http.routers.traefik.service=traefik" | ||
- "traefik.http.routers.traefik.rule=Host(`proxy.localhost`)" | ||
- "traefik.http.routers.traefik.tls=true" | ||
|
||
networks: | ||
uccser-development-proxy: | ||
driver: bridge | ||
# Set name so not scoped with stack name | ||
name: uccser-development-proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Defines openings for incoming requests | ||
entryPoints: | ||
web: | ||
address: ":80" | ||
# Global redirect from HTTP to HTTPS | ||
http: | ||
redirections: | ||
entryPoint: | ||
to: web-secure | ||
scheme: https | ||
web-secure: | ||
address: ":443" | ||
|
||
providers: | ||
docker: | ||
endpoint: "unix:///var/run/docker.sock" | ||
watch: true | ||
exposedByDefault: false | ||
file: | ||
directory: "/etc/traefik/" | ||
watch: true | ||
|
||
tls: | ||
certificates: | ||
- certFile: "/etc/traefik/cert.pem" | ||
keyFile: "/etc/traefik/key.pem" | ||
|
||
log: | ||
level: INFO | ||
format: common | ||
|
||
global: | ||
sendAnonymousUsage: false | ||
|
||
api: | ||
dashboard: true | ||
insecure: true |