Skip to content

Commit de1e826

Browse files
authored
Merge pull request #62 from scality/bugfix/RELENG-6332-invalid-input-ingress-conf
RELENG-6332 configure middleware through env
2 parents d697cc8 + f5578c0 commit de1e826

File tree

4 files changed

+64
-7
lines changed

4 files changed

+64
-7
lines changed

.github/workflows/build.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: build
3+
4+
on:
5+
push:
6+
branches:
7+
- 'user/**'
8+
- 'feature/**'
9+
- 'improvement/**'
10+
- 'bugfix/**'
11+
- 'dependabot/**'
12+
- 'w/**'
13+
- 'q/**'
14+
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Docker Buildk
24+
uses: docker/setup-buildx-action@v1
25+
26+
- name: Login to Registry
27+
uses: docker/login-action@v1
28+
with:
29+
registry: registry.scality.com
30+
username: ${{ secrets.REGISTRY_LOGIN }}
31+
password: ${{ secrets.REGISTRY_PASSWORD }}
32+
33+
- name: Build and push
34+
uses: docker/build-push-action@v2
35+
with:
36+
context: .
37+
file: ./Dockerfile
38+
push: true
39+
tags: "registry.scality.com/bert-e-dev/bert-e:${{ github.sha }}"
40+
cache-from: type=gha,scope=bert-e
41+
cache-to: type=gha,mode=max,scope=bert-e

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [3.6.21] - 2022-08-05
5+
# Added
6+
- Making reverse proxy configuration through env.
7+
# Fixed
8+
- Wsgi config for http scheme had a typo.
9+
410
## [3.6.19] - 2022-06-30
511
# Fixed
612
- Ensure check suites build status are stored on webhook event.

bert_e/server/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,22 @@ def setup_server(bert_e):
7070
"""Create and configure Flask server app."""
7171
app = Flask(__name__)
7272

73+
app_prefix = os.getenv('APP_PREFIX', '/')
74+
app_scheme = os.getenv('APP_SCHEME', None)
75+
app_server = os.getenv('APP_SERVER', None)
7376
app.config.update({
7477
'WEBHOOK_LOGIN': os.environ['WEBHOOK_LOGIN'],
7578
'WEBHOOK_PWD': os.environ['WEBHOOK_LOGIN'],
7679
'CLIENT_ID': os.environ['BERT_E_CLIENT_ID'],
7780
'CLIENT_SECRET': os.environ['BERT_E_CLIENT_SECRET'],
7881
'WTF_CSRF_SECRET_KEY': secrets.token_hex(24),
7982
})
80-
81-
app.wsgi_app = ReverseProxied(app.wsgi_app)
83+
app.wsgi_app = ReverseProxied(
84+
app.wsgi_app,
85+
app_prefix,
86+
app_scheme,
87+
app_server
88+
)
8289

8390
app.bert_e = bert_e
8491

bert_e/server/reverse_proxy.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,26 @@ class ReverseProxied(object):
2323
- app: the WSGI application
2424
2525
"""
26-
def __init__(self, app):
26+
def __init__(self, app, prefix=None, scheme=None, server=None):
2727
self.app = app
28+
self.prefix = prefix
29+
self.scheme = scheme
30+
self.server = server
2831

2932
def __call__(self, environ, start_response):
30-
script_name = environ.get('HTTP_X_SCRIPT_NAME', None)
33+
script_name = self.prefix
3134
if script_name is not None:
3235
environ['SCRIPT_NAME'] = script_name
3336
path_info = environ['PATH_INFO']
3437
if path_info.startswith(script_name):
3538
path_info = path_info[len(script_name):]
3639
environ['PATH_INFO'] = path_info
3740

38-
scheme = environ.get('HTTP_X_SCHEME', None)
41+
scheme = self.scheme
3942
if scheme is not None:
40-
environ['wsgi_url_scheme'] = scheme
43+
environ['wsgi.url_scheme'] = scheme
4144

42-
server = environ.get('HTTP_X_FORWARDED_SERVER', None)
45+
server = self.server
4346
if server:
4447
environ['HTTP_HOST'] = server
4548

0 commit comments

Comments
 (0)