From 5399eede869f05eed25e003ccd4af4408ca61862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A6=E9=82=A6=E9=82=A6=E9=82=A6?= <15622356989@163.com> Date: Thu, 20 Mar 2025 20:32:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0nginx=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/nginx.conf | 41 ++++++++++++++++++++++------------------- static/404.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ static/error.html | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 static/404.html create mode 100644 static/error.html diff --git a/deploy/nginx.conf b/deploy/nginx.conf index 54977b9f6..a2d2eafb5 100644 --- a/deploy/nginx.conf +++ b/deploy/nginx.conf @@ -1,4 +1,3 @@ - worker_processes auto; error_log /var/log/nginx/error.log warn; @@ -15,9 +14,9 @@ events { http { include /etc/nginx/mime.types; - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; + log_format main '[$time_local] remote_addr: $http_x_real_ip, request: "$request", ' + 'status: $status, body_bytes_sent: $body_bytes_sent, http_referer: "$http_referer", ' + 'http_user_agent: "$http_user_agent"'; access_log /var/log/nginx/access.log main; @@ -71,12 +70,14 @@ http { return 444; } - location / { + proxy_set_header X-Forwarded-For $http_x_real_ip; + proxy_set_header Host $host; + add_header X-XSS-Protection "1; mode=block"; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; - add_header Content-Security-Policy "script-src 'self' https://hm.baidu.com https://unpkg.com/@opensig/ 'unsafe-inline' 'unsafe-eval'; object-src 'none'; frame-src 'none'"; + add_header Content-Security-Policy "script-src 'self' 'unsafe-eval' https://hm.baidu.com https://unpkg.com/@opensig/ 'unsafe-inline'; object-src 'none'; frame-src 'none'"; add_header Cache-Control "no-cache,no-store,must-revalidate"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; add_header Pragma no-cache; @@ -96,13 +97,9 @@ http { index index.html index.htm; } - error_page 404 /zh/404.html; - - location = /zh/404.html { - root /usr/share/nginx/html; - } - location /api-search/ { + proxy_set_header X-Forwarded-For $http_x_real_ip; + proxy_pass https://doc-search.opengauss.org/; } @@ -110,18 +107,24 @@ http { proxy_pass https://dsapi.osinfra.cn/; proxy_set_header X-Forwarded-For $http_x_real_ip; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Frame-Options DENY; - add_header X-Content-Type-Options nosniff; - add_header Content-Security-Policy "script-src 'self'; object-src 'none'; frame-src 'none'"; - add_header Cache-Control "no-cache,no-store,must-revalidate"; - add_header Pragma no-cache; - add_header Expires 0; + } location ~ /\. { deny all; return 404; } + + error_page 401 402 403 405 406 407 413 414 /error.html; + error_page 500 501 502 503 504 505 /error.html; + error_page 404 /404.html; + + location = /error.html { + root /usr/share/nginx/www; + } + + location = /404.html { + root /usr/share/nginx/www; + } } } diff --git a/static/404.html b/static/404.html new file mode 100644 index 000000000..07dd21b9d --- /dev/null +++ b/static/404.html @@ -0,0 +1,45 @@ + + + +
+ + + +404 Page Not Found
+Error
+