X-Forwarded headers not handled with Nginx + FPM
@wrenix đang làm issue này rồi.
Từ ngày 24/1/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Describe your Issue
I run Nextcloud behind a Openstack Octavia Loadbalancer (with HTTPS termination), that send X-Forwarded-For, X-Forwarded-Port and X-Forwarded-Proto headers to the Nginx ingress controller.
The LB pool is configured to use the Proxy Protocol in order to preserve client source IP.
Natively, the chart does not allow me to pass these headers from Nginx to PHP-FPM, so I had to create a custom configuration.
Also, the documentation is wrong about trusted_proxies Nextcloud parameter. In our case, it should be equal to ['127.0.0.1'], since the Nextcloud instance and the Nginx webserver are running under the same pod, and since the trafic is forwarded to the PHP upstream on 127.0.0.1 too.
Logs and Errors
Under Nextcloud Administration Area > Admin Settings > Security, the recognized IP is something like ::ffff:10.42.X.X this is the address of the rke2-nginx-ingress-controller, with a helm configuration that is supposed to be correct (I think)
On the Nginx container logs, $http_x_forwarded_for log value is correct, but not transmitted to PHP.
Describe your Environment
-
Kubernetes distribution: RKE2 v1.31
-
Argo-CD Version : v2.13.1+af54ef8
-
Helm Version : v3.15.4+gfa9efb0
-
Helm Chart Version: 6.5.1
-
values.yaml: (issue non relative content is removed)
ingress:
annotations:
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-headers: "X-Forwarded-For"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nextcloud:
configs:
proxy.config.php: |-
<?php
$CONFIG = array (
'trusted_proxies' => array('127.0.0.1'),
'forwarded_for_headers' => array('HTTP_X_FORWARDED_FOR')
);
nginx:
ipFamilies:
- IPv4
- IPv6
config:
default: false
custom: |-
map $http_x_forwarded_proto $fastcgi_https {
default "";
https "on";
}
...
server {
set_real_ip_from 10.42.0.0/16; # My pod IPv4 subnet
set_real_ip_from fd00:42::/56; # My pod IPv6 subnet
real_ip_header X-Forwarded-For;
real_ip_recursive on;
location ~ \.php(?:$|/) {
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SERVER_PORT $http_x_forwarded_port;
...
}
...
}
Additional context, if any
With this solution, you can pass all the headers that I mentionned. Working fine :)
Creating conditions on the Helm chart, it would be great to implement these fixes.
- Ngôn ngữ chính
- Go Template
- Star
- 537
- Fork
- 317
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nextcloud/helm
-
No native support for REDIS_USER enviroment varCó thể đã có người làm @jholmes802 đã nhận 13 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Failed to inspect imageĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Nextcloud pods run as the namespace's default service account: the chart's account is only created with rbac.enabled, which binds the removed PodSecurityPolicyCó thể đã có người làm @martin-mat đã nhận 5 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
-
nextcloud.openmetrics.allowedClients is silently ignored unless nextcloud.configs is setCó thể đã có người làm @JanWelker đã nhận 30 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100