Skip to content

Instantly share code, notes, and snippets.

@abdennour
Created November 10, 2021 17:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdennour/f38c429d53993ad79fb0dbc3d1ba7f70 to your computer and use it in GitHub Desktop.
Save abdennour/f38c429d53993ad79fb0dbc3d1ba7f70 to your computer and use it in GitHub Desktop.
Using Nginx Templates for building custom container images
FROM nginx:1.19-alpine-perl
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx
COPY my-nginx.conf.template /etc/nginx/templates/
version: '3'
services:
app:
build: .
environment:
INGRESS_HOSTNAME: git.example.com
BACKEND_HOSTNAME: 192.168.11.34
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
# include /etc/nginx/mime.types;
default_type application/octet-stream;
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;
#gzip on;
server {
listen 80;
location / {
proxy_set_header Host "$INGRESS_HOSTNAME";
proxy_pass http://$BACKEND_HOSTNAME;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment