From 547d96ea2c5aa6ad0380f0730978d61a19afcbbc Mon Sep 17 00:00:00 2001 From: 13078417792 <397201698@qq.com> Date: Sun, 6 Jun 2021 10:37:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E4=BA=8Enginx=20docker=20=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E9=95=9C=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 ++++++++++++------- Node.Dockerfile | 15 +++++++++++++++ frpc.ini | 4 ++-- nginx.conf | 12 +++--------- 4 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 Node.Dockerfile diff --git a/Dockerfile b/Dockerfile index f2d2bffd..13796b50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,21 @@ -FROM node:lts +FROM node:lts as dist WORKDIR /src COPY . . -RUN yarn global add http-server && \ - npm install pm2 -g && \ - yarn && \ +RUN yarn && \ yarn build:prod + +FROM nginx:1.19.2 + +WORKDIR /app + +COPY --from=dist /src/dist . + +COPY nginx.conf /etc/nginx/nginx.conf + EXPOSE 80 -# CMD ["http-server","/src/dist","-p","80"] - -CMD ["bash","http.sh"] \ No newline at end of file +CMD ["nginx","-g","daemon off;"] \ No newline at end of file diff --git a/Node.Dockerfile b/Node.Dockerfile new file mode 100644 index 00000000..dbd25ebd --- /dev/null +++ b/Node.Dockerfile @@ -0,0 +1,15 @@ +FROM node:lts + +WORKDIR /src + +COPY . . + +RUN yarn && \ + yarn build:prod && \ + yarn global add pm2 http-server + +EXPOSE 80 + +# CMD ["http-server","/src/dist","-p","80"] + +CMD ["bash","http.sh"] \ No newline at end of file diff --git a/frpc.ini b/frpc.ini index f00da160..11d0248f 100644 --- a/frpc.ini +++ b/frpc.ini @@ -10,8 +10,8 @@ admin_pwd = 39zcj [http-demo-admin-ci] type = http -custom_domains = demo-admin.ryio.cn -local_ip = nginx +custom_domains = demo.ryio.cn +local_ip = web local_port = 80 remote_port = 80 use_encryption = true diff --git a/nginx.conf b/nginx.conf index 381021a2..a65cffce 100644 --- a/nginx.conf +++ b/nginx.conf @@ -58,21 +58,15 @@ http { # Virtual Host Configs ## - include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; server { listen 80; - server_name demo-admin.ryio.cn; location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_set_header REMOTE-HOST $remote_addr; - - proxy_pass http://wev/; + root /app; + index index.html; + try_files $uri $uri/ /index.html; } }