Skip to content

Instantly share code, notes, and snippets.

@monosoul
Created August 19, 2023 01:33
Show Gist options
  • Save monosoul/e462b03cba5542bfc52f135417a8209d to your computer and use it in GitHub Desktop.
Save monosoul/e462b03cba5542bfc52f135417a8209d to your computer and use it in GitHub Desktop.
Unprivileged nginx with custom UID and templates
server {
listen 8080;
server_name .${REDIRECT_FROM};
return 301 $scheme://${REDIRECT_TO}$request_uri;
}
version: "3.9"
services:
unprivileged-nginx:
user: 1014:1014
image: nginxinc/nginx-unprivileged:alpine
tmpfs:
- /tmp/nginx/conf.d:rw,exec,nosuid,nodev,size=10M,uid=1014,gid=1014
volumes:
- ./include-tmp.conf:/etc/nginx/conf.d/10-include-tmp.conf:ro
- ./default.conf.template:/etc/nginx/templates/default.conf.template:ro
environment:
- REDIRECT_FROM=some.domain # example var used in template
- REDIRECT_TO=other.domain # example var used in template
- NGINX_ENVSUBST_OUTPUT_DIR=/tmp/nginx/conf.d
include /tmp/nginx/conf.d/*.conf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment