Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

refactor: use correct ragflow.conf as nginx config file (#20321)

Jin Hai1c6cf38e3e0d
diff --git a/Dockerfile b/Dockerfile
index d38befa62e..1e15f70a46 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -243,8 +243,7 @@ COPY --chmod=755 docker/entrypoint*.sh ./
RUN mkdir -p /etc/nginx/conf.d /var/log/nginx
COPY docker/nginx/nginx.conf docker/nginx/proxy.conf /etc/nginx/
-COPY docker/nginx/ragflow.conf.golang \
- /etc/nginx/conf.d/
+COPY docker/nginx/ragflow.conf /etc/nginx/conf.d/
RUN rm -f /etc/nginx/sites-enabled/default
diff --git a/Dockerfile_ci b/Dockerfile_ci
index 695f4d18a5..dc6ba86b78 100644
--- a/Dockerfile_ci
+++ b/Dockerfile_ci
@@ -87,10 +87,7 @@ RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
RUN mkdir -p /etc/nginx/conf.d /var/log/nginx
COPY docker/nginx/nginx.conf docker/nginx/proxy.conf /etc/nginx/
-COPY docker/nginx/ragflow.conf.golang \
- docker/nginx/ragflow.conf.python \
- docker/nginx/ragflow.conf.hybrid \
- /etc/nginx/conf.d/
+COPY docker/nginx/ragflow.conf /etc/nginx/conf.d/
RUN rm -f /etc/nginx/sites-enabled/default
diff --git a/docker/entrypoint-go.sh b/docker/entrypoint-go.sh
index e76ab4adc2..07ba2ba480 100755
--- a/docker/entrypoint-go.sh
+++ b/docker/entrypoint-go.sh
@@ -131,14 +131,6 @@ done < "${TEMPLATE_FILE}"
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/"
-# -----------------------------------------------------------------------------
-# Select Nginx Configuration
-# -----------------------------------------------------------------------------
-# This image ships the Go backend only, so the golang config is the only one
-# available.
-NGINX_CONF_DIR="/etc/nginx/conf.d"
-cp -f "$NGINX_CONF_DIR/ragflow.conf.golang" "$NGINX_CONF_DIR/ragflow.conf"
-
# -----------------------------------------------------------------------------
# Function(s)
# -----------------------------------------------------------------------------
diff --git a/docker/nginx/ragflow.conf.python b/docker/nginx/ragflow.conf
similarity index 96%
rename from docker/nginx/ragflow.conf.python
rename to docker/nginx/ragflow.conf
index 0d62e32417..51b0f7fa81 100644
--- a/docker/nginx/ragflow.conf.python
+++ b/docker/nginx/ragflow.conf
@@ -15,7 +15,7 @@ server {
include proxy.conf;
}
- location ~ ^/(v1|api) {
+ location ~ ^/api/v1 {
proxy_pass http://127.0.0.1:9380;
include proxy.conf;
}
@@ -31,4 +31,4 @@ server {
expires 10y;
access_log off;
}
-}
+}
\ No newline at end of file
diff --git a/docker/nginx/ragflow.conf.golang b/docker/nginx/ragflow.conf.golang
deleted file mode 100644
index 0c04b43d2a..0000000000
--- a/docker/nginx/ragflow.conf.golang
+++ /dev/null
@@ -1,59 +0,0 @@
-server {
- listen 80;
- server_name _;
- root /ragflow/web/dist;
-
- gzip on;
- gzip_min_length 1k;
- gzip_comp_level 9;
- gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
- gzip_vary on;
- gzip_disable "MSIE [1-6]\.";
-
- location ~ ^/api/v1/admin {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/skills {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/(v1|api) {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/datasets/search {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/chat/completions {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/v1/system/config {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/v1/user/(login|logout) {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
-
- location / {
- index index.html;
- try_files $uri $uri/ /index.html;
- }
-
- # Cache-Control: max-age Expires
- location ~ ^/static/(css|js|media)/ {
- expires 10y;
- access_log off;
- }
-}
diff --git a/docker/nginx/ragflow.conf.hybrid b/docker/nginx/ragflow.conf.hybrid
deleted file mode 100644
index 275e817b0c..0000000000
--- a/docker/nginx/ragflow.conf.hybrid
+++ /dev/null
@@ -1,78 +0,0 @@
-server {
- listen 80;
- server_name _;
- root /ragflow/web/dist;
-
- gzip on;
- gzip_min_length 1k;
- gzip_comp_level 9;
- gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
- gzip_vary on;
- gzip_disable "MSIE [1-6]\.";
-
- location ~ ^/api/v1/admin/roles_with_permission {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/admin/sandbox {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/admin/roles {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/admin/whitelist {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/admin/variables {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/admin {
- proxy_pass http://127.0.0.1:9381;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/skills {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/api/v1/chat/completions {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/v1/system/config {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/v1/user/(login|logout) {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location ~ ^/(v1|api) {
- proxy_pass http://127.0.0.1:9380;
- include proxy.conf;
- }
-
- location / {
- index index.html;
- try_files $uri $uri/ /index.html;
- }
-
- # Cache-Control: max-age Expires
- location ~ ^/static/(css|js|media)/ {
- expires 10y;
- access_log off;
- }
-}
diff --git a/internal/common/trusted_proxies.go b/internal/common/trusted_proxies.go
index cd3753cbe1..33e4c675c5 100644
--- a/internal/common/trusted_proxies.go
+++ b/internal/common/trusted_proxies.go
@@ -22,14 +22,6 @@ import (
"github.com/gin-gonic/gin"
)
-// DefaultTrustedProxies is the proxy set whose X-Forwarded-For / X-Real-IP
-// headers gin honours when no `ragflow.trusted_proxies` list is configured.
-// It covers the nginx that docker/entrypoint.sh starts inside the same
-// container as this server: docker/nginx/ragflow.conf.golang proxies /v1 and
-// /api to 127.0.0.1:9380 and proxy.conf appends the caller to
-// X-Forwarded-For. Nothing else is trusted, so a request that reaches the
-// server from any other peer is attributed to that peer regardless of the
-// headers it carries.
var DefaultTrustedProxies = []string{"127.0.0.0/8", "::1/128"}
// ConfigureTrustedProxies replaces gin's default trust-everything proxy list
diff --git a/internal/handler/agent_webhook_security_test.go b/internal/handler/agent_webhook_security_test.go
index fe69e87ea1..66900a6a2b 100644
--- a/internal/handler/agent_webhook_security_test.go
+++ b/internal/handler/agent_webhook_security_test.go
@@ -517,13 +517,6 @@ func TestValidateIPWhitelist_AllowsRealPeerDespiteSpoof(t *testing.T) {
}
}
-// TestValidateIPWhitelist_BehindBundledProxy covers the shipped deployment:
-// docker/entrypoint.sh runs nginx in the same container and
-// docker/nginx/ragflow.conf.golang proxies the webhook route to
-// 127.0.0.1:9380 with X-Forwarded-For set by proxy.conf. The socket peer is
-// therefore always loopback and the whitelist has to be evaluated against
-// the forwarded address, which the loopback default in
-// common.DefaultTrustedProxies makes gin.ClientIP() return.
func TestValidateIPWhitelist_BehindBundledProxy(t *testing.T) {
cfg := map[string]any{"ip_whitelist": []any{"203.0.113.7"}}