diff --git a/proxy/Dockerfile b/proxy/Dockerfile new file mode 100644 index 0000000..564e66c --- /dev/null +++ b/proxy/Dockerfile @@ -0,0 +1,24 @@ +FROM nginxinc/nginx-unprivileged:1-alpine +LABEL maintainer="andrewkassab@live.com" + +COPY ./default.conf.tpl /etc/nginx/default.conf.tpl +COPY ./uwsgi_params /etc/nginx/uwsgi_params +COPY ./run.sh /run.sh + +ENV LISTEN_PORT=8000 +ENV APP_HOST=app +ENV APP_PORT=9000 + +USER root + +RUN mkdir -p /vol/static && \ + chmod 755 /vol/static && \ + touch /etc/nginx/conf.d/default.conf && \ + chown nginx:nginx /etc/nginx/conf.d/default.conf && \ + chmod +x /run.sh + +VOLUME /vol/static + +USER nginx + +CMD ["/run.sh"] diff --git a/proxy/default.conf.tpl b/proxy/default.conf.tpl new file mode 100644 index 0000000..9e189b0 --- /dev/null +++ b/proxy/default.conf.tpl @@ -0,0 +1,13 @@ +server { + listen $(LISTEN_PORT}; + + location /static { + alias /vol/static; + } + + location / { + uwsgi_pass ${APP_HOST}:${APP_PORT}; + include /etc/nginx/uwsgi_params; + client_max_body_size 10M; + } +} diff --git a/proxy/run.sh b/proxy/run.sh new file mode 100644 index 0000000..6bfff53 --- /dev/null +++ b/proxy/run.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e + +envsubst < /etc/nginx/default.conf.tpl > /etc/nginx/conf.d/default.conf +nginx -g 'daemon off;' diff --git a/proxy/uwsgi_params b/proxy/uwsgi_params new file mode 100644 index 0000000..246df56 --- /dev/null +++ b/proxy/uwsgi_params @@ -0,0 +1,13 @@ +uwsgi_param QUERY_STRING $query_string; +uwsgi_param REQUEST_METHOD $request_method; +uwsgi_param CONTENT_TYPE $content_type; +uwsgi_param CONTENT_LENGTH $content_length; +uwsgi_param REQUEST_URI $request_uri; +uwsgi_param PATH_INFO $document_uri; +uwsgi_param DOCUMENT_ROOT $document_root; +uwsgi_param SERVER_PROTOCOL $server_protocol; +uwsgi_param REMOTE_ADDR $remote_addr; +uwsgi_param REMOTE_PORT $remote_port; +uwsgi_param SERVER_ADDR $server_addr; +uwsgi_param SERVER_PORT $server_port; +uwsgi_param SERVER_NAME $server_name;