|
| 1 | +# syntax=docker/dockerfile:1.4 |
| 2 | +# Copyright 2010 New Relic, Inc. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +FROM nginx:latest |
| 17 | + |
| 18 | +COPY <<"EOF" /etc/nginx/nginx.conf |
| 19 | +user nginx; |
| 20 | +worker_processes 1; |
| 21 | + |
| 22 | +error_log /var/log/nginx/error.log notice; |
| 23 | +pid /var/run/nginx.pid; |
| 24 | + |
| 25 | +events { |
| 26 | + worker_connections 1024; |
| 27 | +} |
| 28 | + |
| 29 | +http { |
| 30 | + include /etc/nginx/mime.types; |
| 31 | + default_type text/plain; |
| 32 | + |
| 33 | + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| 34 | + '$status $body_bytes_sent "$http_referer" ' |
| 35 | + '"$http_user_agent" "$http_x_forwarded_for"'; |
| 36 | + |
| 37 | + keepalive_timeout 65; |
| 38 | + # HTTP/1.1-3.0 server |
| 39 | + server { |
| 40 | + listen 8080 quic reuseport; |
| 41 | + listen 8080 ssl; |
| 42 | + http2 on; |
| 43 | + |
| 44 | + add_header Alt-Svc 'h3=":8080"; ma=86400'; |
| 45 | + |
| 46 | + ssl_certificate /etc/nginx/ssl/cert.pem; |
| 47 | + ssl_certificate_key /etc/nginx/ssl/cert.pem; |
| 48 | + |
| 49 | + location / { |
| 50 | + return 200 '{"http3": "$http3","http2": "$http2"}'; |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | +EOF |
| 55 | + |
| 56 | +COPY --chmod=0755 <<"EOF" /docker-entrypoint.d/50-generate-cert.sh |
| 57 | +#!/bin/bash |
| 58 | +set -euo pipefail |
| 59 | + |
| 60 | +echo "Generating self signed cert..." |
| 61 | + |
| 62 | +CERTFILE=/etc/nginx/ssl/cert.pem |
| 63 | +mkdir -p $(dirname $CERTFILE) |
| 64 | +openssl req -nodes -newkey rsa:2048 -x509 -keyout $CERTFILE -out $CERTFILE -subj '/CN=localhost' -days 3650 |
| 65 | + |
| 66 | +echo "Self signed cert generated at $CERTFILE." |
| 67 | +EOF |
0 commit comments