Skip to content

Commit

Permalink
chore:配置 nginx 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazi7 committed Oct 21, 2024
1 parent dc29ff1 commit f915a94
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

env:
DOCKER_IMAGE:
env.REGISTRY:

jobs:
build-and-deploy:
Expand All @@ -15,12 +15,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: docker build -t weilai.team:${{ github.sha }} .

# 设置 Docker 构建器,以便构建
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
Expand Down
58 changes: 39 additions & 19 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
server {
listen 80;
server_name your-domain.com; # 你的域名
user nginx;
worker_processes 1;

root /usr/share/nginx/html; # Vue 应用打包后的文件存放目录
index index.html;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

location / {
try_files $uri $uri/ /index.html;
}
events {
worker_connections 1024;
}

location /api/ {
proxy_pass http://backend-service; # 后端 API 的地址
proxy_set_header Host $host;
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;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
# server_name your-domain.com; # 你的域名

root /usr/share/nginx/html; # Vue 应用打包后的文件存放目录
index index.html;

location / {
try_files $uri $uri/ /index.html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc -b && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
Expand All @@ -23,4 +23,4 @@
"vite": "^5.4.8",
"vue-tsc": "^2.1.6"
}
}
}
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
</script>

<template>

dssddsdsds
</template>

<style lang="scss" scoped></style>

0 comments on commit f915a94

Please sign in to comment.