Skip to content

Commit

Permalink
add nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadqur committed Jul 29, 2024
1 parent 2dcfd3f commit b91faf2
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 27 deletions.
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ RUN yum install tar -y
# install nginx
RUN yum install nginx -y

RUN setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx

# chown nginx directories
RUN chown -R gen3:gen3 /var/log/nginx

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

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

RUN mkdir -p /var/tmp/uwsgi_flask_metrics
RUN chown -R gen3:gen3 /var/tmp/uwsgi_flask_metrics
# copy nginx config
COPY ./deployment/nginx/nginx.conf /etc/nginx/nginx.conf


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

# run nginx and gunicorn
COPY ./deployment/scripts/dockerrun.sh /deployment/scripts/dockerrun.sh
CMD ["/deployment/scripts/dockerrun.sh"]

CMD ["/fence/dockerrun.bash"]
49 changes: 39 additions & 10 deletions deployment/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
# reverse proxy for fence
upstream fence {
server localhost:8000;
user gen3;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/lib/nginx/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

server {
listen 80;
server_name localhost;
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
tcp_nopush on;
keepalive_timeout 65;
types_hash_max_size 4096;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {

listen 80;
server_name localhost;

location / {
proxy_pass http://fence;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
3 changes: 0 additions & 3 deletions deployment/scripts/dockerrun.sh

This file was deleted.

2 changes: 1 addition & 1 deletion dockerrun.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ if [ -f /fence/jwt-keys.tar ]; then
fi
)
fi

nginx
gunicorn -c /fence/deployment/wsgi/gunicorn.conf.py
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ markdown = "^3.1.1"
markupsafe = "^2.0.1"

paramiko = ">=2.6.0"
prometheus-client = "<1"
prometheus-client = ">=0.20.0"
psycopg2-binary = "^2.8.3"
PyJWT = "^2.4.0"
python_dateutil = "^2.6.1"
Expand Down

0 comments on commit b91faf2

Please sign in to comment.