-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug-1894955: add nginx container to dev and ci environments
- Loading branch information
Showing
8 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM alpine:latest AS htpasswd | ||
RUN apk add --update apache2-utils && rm -rf /var/cache/apk/* | ||
RUN mkdir -p /etc/htpasswd && htpasswd -bc /etc/htpasswd/antenna.htpasswd developer password | ||
|
||
FROM us-west1-docker.pkg.dev/moz-fx-platform-artifacts/platform-shared-images/nginx-unprivileged:1.22 | ||
RUN rm /etc/nginx/conf.d/* | ||
COPY --from=htpasswd /etc/htpasswd/antenna.htpasswd /etc/htpasswd/antenna.htpasswd | ||
COPY nginx.conf /etc/nginx/nginx.conf | ||
COPY *.conf.template /etc/nginx/templates/ | ||
# The default command runs /docker-entrypoint.d/20-envsubst-on-templates.sh, which compiles | ||
# /etc/nginx/templates/*.template files with envsubst and writes them to /etc/nginx/conf.d/ | ||
ENV UPSTREAM=127.0.0.1:8000 | ||
ENV CLIENT_BODY_TIMEOUT=70s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# must be higher than GCLB timeout so that GCLB returns 408 and | ||
# known misbehaving clients don't trigger HTTP 5XX alerts | ||
client_body_timeout $CLIENT_BODY_TIMEOUT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# The nginx docker container has ln -sf /dev/stderr /var/log/nginx/error.log | ||
error_log /var/log/nginx/error.log warn; | ||
pid /tmp/nginx.pid; | ||
|
||
events { | ||
worker_connections 2048; | ||
} | ||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
|
||
default_type application/octet-stream; | ||
|
||
log_format main escape=json | ||
'{' | ||
'"time":"$time_local",' | ||
'"remote_addr":"$remote_addr",' | ||
'"remote_user":"$remote_user",' | ||
'"request":"$request",' | ||
'"status": "$status",' | ||
'"log_type": "access",' | ||
'"bytes_sent": $body_bytes_sent,' | ||
'"request_time": $request_time,' | ||
'"referrer":"$http_referer",' | ||
'"user_agent":"$http_user_agent",' | ||
'"x_forwarded_for":"$http_x_forwarded_for",' | ||
'"x_forwarded_proto":"$http_x_forwarded_proto",' | ||
'"trace":"$http_x_cloud_trace_context"' | ||
'}'; | ||
|
||
# The nginx docker container has ln -sf /dev/stdout /var/log/nginx/access.log | ||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
|
||
keepalive_timeout 620; | ||
|
||
server_tokens off; | ||
|
||
gzip on; | ||
gzip_http_version 1.1; | ||
gzip_comp_level 1; | ||
gzip_vary on; | ||
gzip_proxied any; | ||
gzip_disable "MSIE [1-6]\.(?!.*SV1)"; | ||
gzip_min_length 1100; | ||
gzip_types | ||
text/plain | ||
text/css | ||
application/json | ||
application/x-javascript | ||
text/xml | ||
application/xml | ||
application/xml+rss | ||
text/javascript | ||
application/javascript; | ||
|
||
server { | ||
listen 8080; | ||
|
||
client_max_body_size 25m; | ||
|
||
add_header Strict-Transport-Security "max-age=31536000" always; | ||
|
||
location / { | ||
proxy_set_header x-forwarded-proto $http_x_forwarded_proto; | ||
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
proxy_pass http://upstream_docker; | ||
} | ||
|
||
location = /nginx_status { | ||
stub_status on; | ||
access_log off; | ||
allow 127.0.0.1; | ||
deny all; | ||
} | ||
|
||
location = /__nginxheartbeat__ { | ||
return 200; | ||
} | ||
|
||
location /__broken__ { | ||
proxy_set_header Host $http_host; | ||
proxy_pass http://upstream_docker; | ||
auth_basic "antenna private"; | ||
auth_basic_user_file "/etc/htpasswd/antenna.htpasswd"; | ||
} | ||
} | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
upstream upstream_docker { | ||
server $UPSTREAM; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters