Skip to content

Commit e31d4ba

Browse files
Add reverseproxy dockerfile and configuration (#1499)
1 parent ddc6f08 commit e31d4ba

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

.github/workflows/build.yml

+30-7
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,24 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v2
2121

22-
- name: Docker meta
23-
id: meta
22+
- name: Docker app meta
23+
id: meta-app
2424
uses: docker/metadata-action@v3
2525
with:
2626
images: 933237757710.dkr.ecr.eu-west-1.amazonaws.com/app
2727

28+
- name: Docker reverseproxy meta
29+
id: meta-reverseproxy
30+
uses: docker/metadata-action@v3
31+
with:
32+
images: 933237757710.dkr.ecr.eu-west-1.amazonaws.com/nginx
33+
34+
- name: Set up Docker Buildx
35+
id: build-app
36+
uses: docker/setup-buildx-action@v1
37+
2838
- name: Set up Docker Buildx
29-
id: buildx
39+
id: build-reverseproxy
3040
uses: docker/setup-buildx-action@v1
3141

3242
- name: Cache Docker layers
@@ -50,13 +60,26 @@ jobs:
5060
if: github.event_name != 'pull_request'
5161
uses: aws-actions/amazon-ecr-login@v1
5262

53-
- name: Build and push
54-
id: docker_build
63+
- name: Build and push app
64+
id: docker_build_app
5565
uses: docker/build-push-action@v2
5666
with:
5767
context: .
68+
builder: ${{ steps.build-app.outputs.name }}
69+
push: ${{ github.event_name != 'pull_request' }}
70+
tags: ${{ steps.meta-app.outputs.tags }}
71+
labels: ${{ steps.meta-app.outputs.labels }}
72+
cache-from: type=local,src=/tmp/.buildx-cache
73+
cache-to: type=local,dest=/tmp/.buildx-cache
74+
75+
- name: Build and push reverseproxy
76+
id: docker_build_reverseproxy
77+
uses: docker/build-push-action@v2
78+
with:
79+
context: ./reverseproxy
80+
builder: ${{ steps.build-reverseproxy.outputs.name }}
5881
push: ${{ github.event_name != 'pull_request' }}
59-
tags: ${{ steps.meta.outputs.tags }}
60-
labels: ${{ steps.meta.outputs.labels }}
82+
tags: ${{ steps.meta-reverseproxy.outputs.tags }}
83+
labels: ${{ steps.meta-reverseproxy.outputs.labels }}
6184
cache-from: type=local,src=/tmp/.buildx-cache
6285
cache-to: type=local,dest=/tmp/.buildx-cache

reverseproxy/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:1.20
2+
3+
COPY nginx.conf /etc/nginx/nginx.conf

reverseproxy/nginx.conf

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
worker_processes 1;
2+
3+
events { worker_connections 1024; }
4+
5+
http {
6+
7+
sendfile on;
8+
9+
upstream app {
10+
server 127.0.0.1:8080;
11+
}
12+
13+
server {
14+
listen 80;
15+
server_name $hostname;
16+
location / {
17+
proxy_pass http://app;
18+
proxy_redirect off;
19+
proxy_http_version 1.1;
20+
proxy_cache_bypass $http_upgrade;
21+
proxy_set_header Upgrade $http_upgrade;
22+
proxy_set_header Connection keep-alive;
23+
proxy_set_header Host $host;
24+
proxy_set_header X-Real-IP $remote_addr;
25+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
26+
proxy_set_header X-Forwarded-Proto $scheme;
27+
proxy_set_header X-Forwarded-Host $server_name;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)