This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/answer-website.git


The following commit(s) were added to refs/heads/main by this push:
     new aec2fb59c fix: add nginx.con file (#299)
aec2fb59c is described below

commit aec2fb59c4f7da61d76e034dee150fae59fec9d4
Author: dashuai <[email protected]>
AuthorDate: Mon Feb 17 14:30:52 2025 +0800

    fix: add nginx.con file (#299)
---
 Dockerfile                              |  3 +++
 nginx.conf                              | 31 +++++++++++++++++++++++++++++++
 src/components/HomePageHeader/index.tsx |  2 +-
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 5560e5b24..5a844dede 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 000000000..34009b23b
--- /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 48ed3412a..e350f56e9 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 .*>(.*?)<\/text>/)[1];

Reply via email to