Skip to content

Commit e68929c

Browse files
committed
Added development environment for quickly testing proxy configurations
1 parent 60d6c7e commit e68929c

File tree

5 files changed

+88
-0
lines changed

5 files changed

+88
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,21 @@ config to then take effect.
4646

4747
There is currently no way to remove files or fix a broken config other than mounting the EFS mount into an EC2 server and making changes.
4848
To do this you will need to edit the security group to allow access to the EC2 box and then install the EFS utils.
49+
50+
## Manually adding a file/template
51+
52+
One can execute the httpdmanager lambda function directly with the following json syntax:
53+
54+
```
55+
{
56+
"filename": "example-extension",
57+
"template": "SSLProxyEngine On\nProxyPreserveHost On\n\nProxyPass \/hub https:\/\/jupyter.us-west-2.elb.amazonaws.com:443\/hub\/\nProxyPassReverse \/hub https:\/\/jupyter.us-west-2.elb.amazonaws.com:443\/hub\/"
58+
}
59+
60+
```
61+
62+
The template must be json encoded. I've used https://nddapp.com/json-encoder.html successfully.
63+
64+
65+
## How do I know what to add in the 'template' file above?
66+
We are not perfect human beings. In order to iterate quickly on the above templat contents, we have created a development proxy environment that can be tested mostly locally. Check out the `develop` directory for instructions.

develop/Dockerfile.developer

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM ubuntu/apache2
2+
LABEL authors="barber"
3+
4+
RUN apt update && apt install -y libapache2-mod-auth-openidc ca-certificates && a2enmod auth_openidc proxy proxy_http proxy_wstunnel rewrite headers ssl && \
5+
sed -i 's/Listen 80/Listen 8080/' /etc/apache2/ports.conf
6+
7+
8+
CMD ["/bin/bash", "-c", "apache2-foreground"]

develop/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Developing for the proxy
2+
3+
## Build the docker container locally
4+
5+
```
6+
docker build -t unity-proxy-dev -f Dockerfile.developer .
7+
```
8+
9+
We need a "special" proxy without the management console additions present. Ideally the proxy would not be tied to the management console, but here we are.
10+
11+
## Add files to the sites-enabled folder
12+
13+
The proxy works by looking at "conf" files in the "sites-enabled" directory within apache (within the container, this is /etc/apache2/sites-enabled). To facillitate dynamic additions, the unity-proxy code allows for individualized configurations to be added. This is done in two areas:
14+
15+
1. Add a `*.conf` file to the sites-enabled directory. This is where you want to put all your proxy informations. DO NOT INCLUDE `<VirtualHost>` tags within this.
16+
2. Add an 'Include' to the `sites-enabled/main.conf` file to include this new entry. Note how the `main.conf` file already defines the <VirtualHost> section? This is why it's not included above.
17+
18+
**Note:** whatever path you end up proxying TO your service will be visible to the user. So, for example, we want something like `jupyter` not `mikes-dev-jupyter` and it should be consistent across ALL venues. Care shoud be taken to make sure you're not conflicting with another service.
19+
20+
21+
## Run the container
22+
```
23+
docker run --name apache2 --rm -p 8080:8080 -v $PWD/sites-enabled:/etc/apache2/sites-enabled 425ffb0c6c2d
24+
```
25+
26+
This will mount the local sites-enabled directory over the default directory so that one can develop quickly. Simply keep tweaking the *.conf file you created until your proxy is working.
27+
28+
You can now navigate to `localhost:8080/<proxyPath>` to test out your proxy params.
29+
30+
When ready, kill your container
31+
32+
```
33+
docker kill apache2
34+
```
35+
36+
## Finalizing
37+
38+
When ready, add your config to the deployed unity-proxy instance, you have all the information needed to follow the instructions in the ../README.md file.
39+
40+
The `filename` should be whatever you named your `*.conf` file WITHOUT the `.conf` suffix. The `template` value should be the contents of your `*.conf` file.
41+
42+
Add these to your terraform script to update the venue proxy with your information.
43+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SSLProxyEngine On
2+
ProxyPreserveHost On
3+
4+
ProxyPass /hub https://jupyter.us-west-2.elb.amazonaws.com:443/hub/
5+
ProxyPassReverse /hub https://jupyter.us-west-2.elb.amazonaws.com:443/hub/
6+

develop/sites-enabled/main.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<VirtualHost *:8080>
2+
3+
# THESE ARE FOR TESTING DEVELOPMENT ONLY, DO NOT ADD THESE TO a deployed config file as they make thigns VERY unsecure.
4+
# SERIOUSLY
5+
# DO NOT ADD THIS IN PRODUCTION
6+
SSLProxyCheckPeerCN Off
7+
SSLProxyCheckPeerExpire Off
8+
SSLProxyCheckPeerName Off
9+
10+
# Add your new *.conf file here
11+
Include /etc/apache2/sites-enabled/example-extension.conf
12+
13+
</VirtualHost>

0 commit comments

Comments
 (0)