Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use NJS for nginx IP anonymization #10151

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions docker/Dockerfile.olbase
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,10 @@ RUN apt-get -qq update && apt-get install -y \
COPY scripts/install_nodejs.sh ./
RUN ./install_nodejs.sh && rm ./install_nodejs.sh

# Install Archive.org nginx w/ IP anonymization
# Install nginx
USER root
RUN apt-get update && apt-get install -y --no-install-recommends nginx curl letsencrypt \
# nginx-plus
apt-transport-https lsb-release ca-certificates wget \
# log rotation service for ol-nginx
logrotate \
# rsync service for pulling monthly sitemaps from ol-home0 to ol-www0
rsync
COPY scripts/install_openresty.sh ./
RUN ./install_openresty.sh && rm ./install_openresty.sh
RUN rm /usr/sbin/nginx
RUN curl -L https://archive.org/download/nginx/nginx -o /usr/sbin/nginx
RUN chmod +x /usr/sbin/nginx
# Remove the stock nginx config file
RUN rm /etc/nginx/sites-enabled/default
COPY scripts/install_nginx.sh ./
RUN ./install_nginx.sh && rm ./install_nginx.sh

RUN mkdir -p /var/log/openlibrary /var/lib/openlibrary && chown openlibrary:openlibrary /var/log/openlibrary /var/lib/openlibrary \
&& mkdir /openlibrary && chown openlibrary:openlibrary /openlibrary \
Expand Down
6 changes: 5 additions & 1 deletion docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Needed for IP anonymization
load_module modules/ngx_http_js_module.so;

user www-data;

# XXX-Anand: Oct 2013
Expand Down Expand Up @@ -25,7 +28,8 @@ http {
server_names_hash_bucket_size 64;
types_hash_bucket_size 64;

log_format iacombined '$remote_addr_ipscrub $host $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_time';
# Logging / IP Anonymization
include /olsystem/etc/nginx/logging.conf;
access_log /var/log/nginx/access.log iacombined;

client_max_body_size 50m;
Expand Down
19 changes: 19 additions & 0 deletions scripts/install_nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash

apt-get update

# log rotation service for ol-nginx
# rsync service for pulling monthly sitemaps from ol-home0 to ol-www0
apt-get install -y --no-install-recommends curl \
logrotate \
rsync \
lsb-release

# Add the NGINX signing key + Repo
curl -fsSL https://nginx.org/keys/nginx_signing.key | tee /usr/share/keyrings/nginx-keyring.asc
echo "deb [signed-by=/usr/share/keyrings/nginx-keyring.asc] http://nginx.org/packages/debian $(lsb_release -cs) nginx" \
> /etc/apt/sources.list.d/nginx.list

# Install nginx and the NJS module
apt-get update
apt-get install -y --no-install-recommends nginx nginx-module-njs letsencrypt
14 changes: 0 additions & 14 deletions scripts/install_openresty.sh

This file was deleted.

Loading