Created
November 10, 2021 17:36
-
-
Save abdennour/f38c429d53993ad79fb0dbc3d1ba7f70 to your computer and use it in GitHub Desktop.
Using Nginx Templates for building custom container images
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
FROM nginx:1.19-alpine-perl | |
ENV NGINX_ENVSUBST_OUTPUT_DIR=/etc/nginx | |
COPY my-nginx.conf.template /etc/nginx/templates/ |
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
version: '3' | |
services: | |
app: | |
build: . | |
environment: | |
INGRESS_HOSTNAME: git.example.com | |
BACKEND_HOSTNAME: 192.168.11.34 |
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
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