From 1d38776351a17bd85d87512b666c94241490ba78 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 17 Feb 2025 14:30:13 +0800 Subject: [PATCH 1/3] fix: add nginx.con file --- Dockerfile | 3 +++ nginx.conf | 31 +++++++++++++++++++++++++ src/components/HomePageHeader/index.tsx | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 5560e5b24f..5a844dede0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM nginx:alpine +RUN rm /etc/nginx/conf.d/default.conf +COPY nginx.conf /etc/nginx/conf.d/default.conf + COPY ./build /usr/share/nginx/html EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000..34009b23bf --- /dev/null +++ b/nginx.conf @@ -0,0 +1,31 @@ +server { + listen 80; + server_name localhost; + + # 静态文件服务 + location / { + root /usr/share/nginx/html; + index index.html; + try_files $uri $uri/ /index.html; + } + + location /github-stars/ { + proxy_pass https://img.shields.io/github/stars/; + proxy_set_header Host img.shields.io; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_ssl_protocols TLSv1.2 TLSv1.3; + proxy_ssl_ciphers HIGH:!aNULL:!MD5; + } + + location /mixpanel/ { + proxy_pass https://api-js.mixpanel.com/track/; + proxy_set_header Host api-js.mixpanel.com; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass_request_headers on; + proxy_pass_request_body on; + } +} diff --git a/src/components/HomePageHeader/index.tsx b/src/components/HomePageHeader/index.tsx index 48ed3412a0..e350f56e90 100644 --- a/src/components/HomePageHeader/index.tsx +++ b/src/components/HomePageHeader/index.tsx @@ -40,7 +40,7 @@ const HomeHead: FC = () => { useEffect(() => { - fetch('https://img.shields.io/github/stars/apache/answer') + fetch('/github-stars/apache/answer') .then((response) => response.text()) .then((data) => { const num = data.match(/(.*?)<\/text>/)[1]; From ed149b50c40a20e519fa1dc6de35a0515604dd66 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 17 Feb 2025 14:41:40 +0800 Subject: [PATCH 2/3] fix: delete nginx.conf file --- Dockerfile | 3 --- nginx.conf | 31 ------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 5a844dede0..5560e5b24f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,5 @@ FROM nginx:alpine -RUN rm /etc/nginx/conf.d/default.conf -COPY nginx.conf /etc/nginx/conf.d/default.conf - COPY ./build /usr/share/nginx/html EXPOSE 80 diff --git a/nginx.conf b/nginx.conf deleted file mode 100644 index 34009b23bf..0000000000 --- a/nginx.conf +++ /dev/null @@ -1,31 +0,0 @@ -server { - listen 80; - server_name localhost; - - # 静态文件服务 - location / { - root /usr/share/nginx/html; - index index.html; - try_files $uri $uri/ /index.html; - } - - location /github-stars/ { - proxy_pass https://img.shields.io/github/stars/; - proxy_set_header Host img.shields.io; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_ssl_protocols TLSv1.2 TLSv1.3; - proxy_ssl_ciphers HIGH:!aNULL:!MD5; - } - - location /mixpanel/ { - proxy_pass https://api-js.mixpanel.com/track/; - proxy_set_header Host api-js.mixpanel.com; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass_request_headers on; - proxy_pass_request_body on; - } -} From 7ad09ede0ff5654966d1f4d8ff8db43da5a01604 Mon Sep 17 00:00:00 2001 From: shuai Date: Mon, 17 Feb 2025 14:42:56 +0800 Subject: [PATCH 3/3] fix: fetch url change --- src/components/HomePageHeader/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HomePageHeader/index.tsx b/src/components/HomePageHeader/index.tsx index e350f56e90..48ed3412a0 100644 --- a/src/components/HomePageHeader/index.tsx +++ b/src/components/HomePageHeader/index.tsx @@ -40,7 +40,7 @@ const HomeHead: FC = () => { useEffect(() => { - fetch('/github-stars/apache/answer') + fetch('https://img.shields.io/github/stars/apache/answer') .then((response) => response.text()) .then((data) => { const num = data.match(/(.*?)<\/text>/)[1];