Skip to content

Commit a543d43

Browse files
authored
Merge pull request #51 from jembi/plat-224-reverse-proxy-improvements
PLAT-224 - reverse proxy improvements
2 parents ce89493 + b62e011 commit a543d43

File tree

14 files changed

+623
-117
lines changed

14 files changed

+623
-117
lines changed

.env.dev

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# General
22

3-
STATEFUL_NODES=cluster
3+
STATEFUL_NODES=single
44

55
# Interoperability Layer - OpenHIM
66

77
OPENHIM_CORE_INSTANCES=1
88
OPENHIM_CONSOLE_INSTANCES=1
9-
OPENHIM_CORE_MEDIATOR_HOSTNAME=localhost
9+
OPENHIM_CORE_MEDIATOR_HOSTNAME=127.0.0.1
1010
OPENHIM_MEDIATOR_API_PORT=8080
1111
MONGO_SET_COUNT=3
1212

@@ -44,9 +44,9 @@ HF_POSTGRES_MEMORY_RESERVE=500M
4444

4545
# Reverse Proxy - Nginx
4646

47-
REVERSE_PROXY_INSTANCES=3
48-
INSECURE=false
49-
INSECURE_PORTS=-5001:5001-80:80-8080:8080
47+
REVERSE_PROXY_INSTANCES=1
48+
INSECURE=true
49+
INSECURE_PORTS=5001:5001-80:80-8080:8080
5050
DOMAIN_NAME=domain
5151
SUBDOMAINS=openhimcomms.domain,openhimcore.domain,openhimconsole.domain
5252
RENEWAL_EMAIL=dummy@jembi.org
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# OpenHIM Core HTTP server config
2+
server {
3+
listen 5001;
4+
client_max_body_size 10M;
5+
6+
location / {
7+
proxy_pass http://openhim-core:5001;
8+
}
9+
}
10+
11+
# OpenHIM Console
12+
server {
13+
listen 80;
14+
15+
location / {
16+
proxy_pass http://openhim-console:80;
17+
}
18+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# OpenHIM Core API server config
2+
server {
3+
listen 80;
4+
server_name openhimcomms.*;
5+
6+
location /.well-known/acme-challenge/ {
7+
resolver 127.0.0.11 valid=30s;
8+
set $upstream_certbot certbot;
9+
proxy_pass http://$upstream_certbot$request_uri;
10+
}
11+
12+
location / {
13+
return 301 https://$host$request_uri;
14+
}
15+
}
16+
server {
17+
listen 443 ssl;
18+
listen [::]:443 ssl;
19+
server_name openhimcomms.*;
20+
21+
location /.well-known/acme-challenge/ {
22+
resolver 127.0.0.11 valid=30s;
23+
set $upstream_certbot certbot;
24+
proxy_pass http://$upstream_certbot$request_uri;
25+
}
26+
27+
location / {
28+
proxy_pass https://openhim-core:8080;
29+
}
30+
}
31+
32+
# OpenHIM Core HTTP server config
33+
server {
34+
listen 80;
35+
server_name openhimcore.*;
36+
37+
location /.well-known/acme-challenge/ {
38+
resolver 127.0.0.11 valid=30s;
39+
set $upstream_certbot certbot;
40+
proxy_pass http://$upstream_certbot$request_uri;
41+
}
42+
43+
location / {
44+
return 301 https://$host$request_uri;
45+
}
46+
}
47+
server {
48+
listen 443 ssl;
49+
listen [::]:443 ssl;
50+
server_name openhimcore.*;
51+
client_max_body_size 10M;
52+
53+
location /.well-known/acme-challenge/ {
54+
resolver 127.0.0.11 valid=30s;
55+
set $upstream_certbot certbot;
56+
proxy_pass http://$upstream_certbot$request_uri;
57+
}
58+
59+
location / {
60+
proxy_pass https://openhim-core:5000;
61+
}
62+
}
63+
64+
# OpenHIM Console
65+
server {
66+
listen 80;
67+
server_name openhimconsole.*;
68+
69+
location /.well-known/acme-challenge/ {
70+
resolver 127.0.0.11 valid=30s;
71+
set $upstream_certbot certbot;
72+
proxy_pass http://$upstream_certbot$request_uri;
73+
}
74+
75+
location / {
76+
return 301 https://$host$request_uri;
77+
}
78+
}
79+
server {
80+
listen 443 ssl;
81+
listen [::]:443 ssl;
82+
server_name openhimconsole.*;
83+
84+
location /.well-known/acme-challenge/ {
85+
resolver 127.0.0.11 valid=30s;
86+
set $upstream_certbot certbot;
87+
proxy_pass http://$upstream_certbot$request_uri;
88+
}
89+
90+
location / {
91+
proxy_pass http://openhim-console:80;
92+
}
93+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# use a stream so don't terminate ssl here
2+
server {
3+
listen 8080;
4+
proxy_pass openhim-core:8080;
5+
}

interoperability-layer-openhim/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
depends_on:
2525
- openhim-core
2626
configs:
27-
- source: console.config
27+
- source: console-default.json
2828
target: /usr/share/nginx/html/config/default.json
2929
deploy:
3030
placement:
@@ -38,7 +38,7 @@ services:
3838
memory: ${OPENHIM_CONSOLE_MEMORY_RESERVE:-500M}
3939

4040
configs:
41-
console.config:
41+
console-default.json:
4242
file: ./importer/volume/default.json
4343
name: console.config-${console_config_DIGEST:?err}
4444
labels:

interoperability-layer-openhim/initiateReplicaSet.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ done
3939
# This sleep ensures that the replica sets are reachable
4040
sleep 10
4141

42+
# TODO (PLAT-256): only works if deploying to node-1 labeled node
43+
# With docker swarm any manager can be the target but this bit of code only work if we target node-1 specifically.
44+
# Which is generally what we do, but if node-1 is down or we choose to target another node this won't work.
4245
ContainerName=""
4346
if [[ "$(docker ps -f name=instant_mongo-1 --format "{{.ID}}")" ]]; then
4447
ContainerName="$(docker ps -f name=instant_mongo-1 --format "{{.ID}}")"

interoperability-layer-openhim/package-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"name": "Interoperability Layer Package - Openhim",
44
"description": "This is the interoperability layer that enables simpler data exchange between the different systems. It is also the security layer for the other systems",
55
"version": "1.0.0",
6+
"dependencies": ["reverse-proxy-nginx"],
67
"environmentVariables": {
78
"mongo_url": "mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/openhim?replicaSet=mongo-set",
89
"mongo_atnaUrl": "mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/openhim?replicaSet=mongo-set",

0 commit comments

Comments
 (0)