Created
August 19, 2023 01:33
-
-
Save monosoul/e462b03cba5542bfc52f135417a8209d to your computer and use it in GitHub Desktop.
Unprivileged nginx with custom UID and templates
This file contains hidden or 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
| server { | |
| listen 8080; | |
| server_name .${REDIRECT_FROM}; | |
| return 301 $scheme://${REDIRECT_TO}$request_uri; | |
| } |
This file contains hidden or 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.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 |
This file contains hidden or 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
| include /tmp/nginx/conf.d/*.conf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment