Skip to content

Commit b91faf2

Browse files
committed
add nginx
1 parent 2dcfd3f commit b91faf2

File tree

6 files changed

+57
-27
lines changed

6 files changed

+57
-27
lines changed

Dockerfile

+11-7
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,20 @@ RUN yum install tar -y
5858
# install nginx
5959
RUN yum install nginx -y
6060

61+
RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx
62+
6163
# chown nginx directories
6264
RUN chown -R gen3:gen3 /var/log/nginx
6365

64-
# copy nginx config
65-
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf
66+
# pipe nginx logs to stdout and stderr
67+
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
6668

69+
# create /var/lib/nginx/tmp/client_body to allow nginx to write to fence
70+
RUN mkdir -p /var/lib/nginx/tmp/client_body
71+
RUN chown -R gen3:gen3 /var/lib/nginx/
6772

68-
RUN mkdir -p /var/tmp/uwsgi_flask_metrics
69-
RUN chown -R gen3:gen3 /var/tmp/uwsgi_flask_metrics
73+
# copy nginx config
74+
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf
7075

7176

7277
# Switch to non-root user 'gen3' for the serving process
@@ -77,6 +82,5 @@ RUN source /venv/bin/activate
7782
ENV PYTHONUNBUFFERED=1 \
7883
PYTHONIOENCODING=UTF-8
7984

80-
# run nginx and gunicorn
81-
COPY ./deployment/scripts/dockerrun.sh /deployment/scripts/dockerrun.sh
82-
CMD ["/deployment/scripts/dockerrun.sh"]
85+
86+
CMD ["/fence/dockerrun.bash"]

deployment/nginx/nginx.conf

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,44 @@
1-
# reverse proxy for fence
2-
upstream fence {
3-
server localhost:8000;
1+
user gen3;
2+
worker_processes auto;
3+
error_log /var/log/nginx/error.log notice;
4+
pid /var/lib/nginx/nginx.pid;
5+
6+
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
7+
include /usr/share/nginx/modules/*.conf;
8+
9+
events {
10+
worker_connections 1024;
411
}
512

6-
server {
7-
listen 80;
8-
server_name localhost;
13+
http {
14+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
15+
'$status $body_bytes_sent "$http_referer" '
16+
'"$http_user_agent" "$http_x_forwarded_for"';
17+
18+
access_log /var/log/nginx/access.log main;
19+
20+
sendfile on;
21+
tcp_nopush on;
22+
keepalive_timeout 65;
23+
types_hash_max_size 4096;
24+
25+
include /etc/nginx/mime.types;
26+
default_type application/octet-stream;
27+
28+
# Load modular configuration files from the /etc/nginx/conf.d directory.
29+
# See http://nginx.org/en/docs/ngx_core_module.html#include
30+
# for more information.
31+
include /etc/nginx/conf.d/*.conf;
32+
33+
server {
34+
35+
listen 80;
36+
server_name localhost;
937

10-
location / {
11-
proxy_pass http://fence;
12-
proxy_set_header Host $host;
13-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+
location / {
39+
proxy_pass http://localhost:8000;
40+
proxy_set_header Host $host;
41+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42+
}
1443
}
1544
}

deployment/scripts/dockerrun.sh

-3
This file was deleted.

dockerrun.bash

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ if [ -f /fence/jwt-keys.tar ]; then
1919
fi
2020
)
2121
fi
22-
22+
nginx
2323
gunicorn -c /fence/deployment/wsgi/gunicorn.conf.py

poetry.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ markdown = "^3.1.1"
3939
markupsafe = "^2.0.1"
4040

4141
paramiko = ">=2.6.0"
42-
prometheus-client = "<1"
42+
prometheus-client = ">=0.20.0"
4343
psycopg2-binary = "^2.8.3"
4444
PyJWT = "^2.4.0"
4545
python_dateutil = "^2.6.1"

0 commit comments

Comments
 (0)