Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

31 changes: 31 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
2 changes: 1 addition & 1 deletion src/components/HomePageHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down