From 13c58500c105583f6c436f50149d38aad3fad296 Mon Sep 17 00:00:00 2001 From: none Date: Tue, 30 May 2023 11:50:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 11 +++++------ conf/nginx.conf | 34 +++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 7a1c772..dc5ab33 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ docker build -t playedu-light . 执行完毕之后,可运行下面命令将 PlayEdu 服务跑起来: ``` -docker run -d -p 9898:80 --name playedu-local \ +docker run -d -p 9800:9800 -p 9900:9900 --name playedu-local \ -e DB_HOST=数据库host \ -e DB_PORT=数据库端口 \ -e DB_NAME=数据库名 \ @@ -36,8 +36,7 @@ docker run -d -p 9898:80 --name playedu-local \ 跑起来之后,可以通过下面的链接访问前后台: -| 端口 | 地址 | -| -------- | ----------------------------- | -| 学员界面 | `http://localhost:9898` | -| 后台管理 | `http://localhost:9898/admin` | -| API 服务 | `http://localhost:9898/api` | +| 端口 | 地址 | +| -------- | ----------------------- | +| 学员界面 | `http://localhost:9800` | +| 后台管理 | `http://localhost:9900` | diff --git a/conf/nginx.conf b/conf/nginx.conf index c7a1001..4c61dab 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ server { - listen 80 default_server; + listen 9800 default_server; absolute_redirect off; server_name _; @@ -24,11 +24,25 @@ server { proxy_pass http://127.0.0.1:9898/; } - location /admin { - alias /app/backend; - index index.html; - - try_files $uri $uri/ /admin/index.html; + location ~ /\.ht { + deny all; + } + + location ~* ^/(?![api].*) { + try_files $uri /index.html; + } +} + +server { + listen 9900 default_server; + absolute_redirect off; + server_name _; + + root /app/backend; + index index.html; + + location / { + try_files $uri $uri/ /index.html; gzip on; gzip_static on; @@ -37,13 +51,19 @@ server { gzip_comp_level 5; gzip_types text/plain application/javascript text/css application/xml text/javascript; gzip_vary on; + } + + location /api/ { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:9898/; } location ~ /\.ht { deny all; } - location ~* ^/(?![api|admin].*) { + location ~* ^/(?![api].*) { try_files $uri /index.html; } } \ No newline at end of file