|
@@ -11,4 +11,24 @@
|
|
|
7. 升级community-user包
|
|
|
8. 升级vip包
|
|
|
9. 第三方登录屏蔽
|
|
|
-```
|
|
|
+```
|
|
|
+#### ngress-nginx获取用户真实IP
|
|
|
+k8s ingress-nginx获取用户IP默认是通过$remote_addr参数,nginx.conf中配置如下:
|
|
|
+```
|
|
|
+proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
+```
|
|
|
+但是,如果用户通过代理或使用waf转发请求的话,上面这种方式是无法拿到用户的真实IP。因此,就需要k8s中添加下面的配置获取真实IP。
|
|
|
+
|
|
|
+1、在ConfigMaps的ngress-nginx-controller中添加下面的配置:
|
|
|
+```
|
|
|
+data:
|
|
|
+ compute-full-forwarded-for: 'true'
|
|
|
+ use-forwarded-headers: 'true'
|
|
|
+```
|
|
|
+2、在Ingresses找到对应项目的Ingress配置,添加如下内容:
|
|
|
+```
|
|
|
+kubernetes.io/ingress.class: nginx
|
|
|
+ nginx.ingress.kubernetes.io/configuration-snippet: |
|
|
|
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
+```
|
|
|
+
|