浏览代码

nginx: Documented UID changes and how to run as an arbitrary user

Konstantin Pavlov 6 年之前
父节点
当前提交
6e08960e34
共有 1 个文件被更改,包括 35 次插入0 次删除
  1. 35 0
      nginx/content.md

+ 35 - 0
nginx/content.md

@@ -118,6 +118,41 @@ web:
   command: [nginx-debug, '-g', 'daemon off;']
 ```
 
+## User and group id
+
+Since 1.17.0, both alpine- and debian-based images variants use the same user and group ids to drop the privileges for worker processes:
+
+```
+uid=101(nginx) gid=101(nginx) groups=101(nginx)
+```
+
+## Running %%IMAGE%% as a non-root user
+
+It is possible to run the image as a less privileged arbitrary UID/GID.  This, however, requires modification of %%IMAGE%% configuration to use directories writeable by that specific UID/GID pair:
+
+```console
+$ docker run -d -v $PWD/nginx.conf:/etc/nginx/nginx.conf %%IMAGE%%
+```
+
+where nginx.conf in the current directory should have the following directives re-defined:
+
+```
+pid        /tmp/nginx.pid;
+```
+
+And in the http context:
+
+```
+http {
+    client_body_temp_path /tmp/client_temp;
+    proxy_temp_path       /tmp/proxy_temp_path;
+    fastcgi_temp_path     /tmp/fastcgi_temp;
+    uwsgi_temp_path       /tmp/uwsgi_temp;
+    scgi_temp_path        /tmp/scgi_temp;
+...
+}
+```
+
 ## Monitoring nginx with Amplify
 
 [Amplify](https://amplify.nginx.com/signup/) is a free monitoring tool that can be used to monitor microservice architectures based on nginx. Amplify is developed and maintained by the company behind the nginx software.