From 646295363a2b1b5608f6b06c0b8f7a92b3eb91c0 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Thu, 17 Mar 2022 22:38:07 +0800 Subject: [PATCH] updated nginx configs for myems-admin and myems-web --- README.md | 1 + README_DE.md | 1 + README_EN.md | 1 + myems-admin/Dockerfile | 5 ++--- myems-admin/README.md | 27 +++++++++++++-------------- myems-admin/nginx.conf | 4 ++-- myems-web/Dockerfile | 4 ++-- myems-web/README.md | 24 ++++++++++++------------ myems-web/nginx.conf | 4 ++-- 9 files changed, 36 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 564f2f91..4e6fd29f 100644 --- a/README.md +++ b/README.md @@ -230,4 +230,5 @@ administrator@myems.io ## QQ交流群 群号: 792528967 + ![QQ群](/docs/images/qq-group.png) \ No newline at end of file diff --git a/README_DE.md b/README_DE.md index 6b5b33ed..7ca907ec 100644 --- a/README_DE.md +++ b/README_DE.md @@ -226,4 +226,5 @@ Sehen [Kooperationsplan für Integrationstests](integration-testing-cn.md) ## QQ-Gruppe Gruppennummer: 792528967 + ![QQ Group 1](/docs/images/qq-group-1.png) \ No newline at end of file diff --git a/README_EN.md b/README_EN.md index 7eefefb3..cbdbc104 100644 --- a/README_EN.md +++ b/README_EN.md @@ -228,4 +228,5 @@ See [Integration Testing Cooperation Plan](integration-testing-cn.md) ## QQ Group Group Number: 792528967 + ![QQ Group 1](/docs/images/qq-group-1.png) \ No newline at end of file diff --git a/myems-admin/Dockerfile b/myems-admin/Dockerfile index a9301477..89a1bdf1 100644 --- a/myems-admin/Dockerfile +++ b/myems-admin/Dockerfile @@ -5,11 +5,10 @@ RUN rm /etc/nginx/conf.d/default.conf && \ rm /etc/nginx/nginx.conf # create new root folder -# todo: share upload folder in admin with myems-api container on Docker -RUN mkdir -p /var/www/html/admin +RUN mkdir -p /var/www/myems-admin # copy the config and web codes COPY nginx.conf /etc/nginx/ -COPY . /var/www/html/admin +COPY . /var/www/myems-admin EXPOSE 8001 CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"] \ No newline at end of file diff --git a/myems-admin/README.md b/myems-admin/README.md index bf399552..98d59cc4 100644 --- a/myems-admin/README.md +++ b/myems-admin/README.md @@ -44,11 +44,11 @@ docker build -t myems/myems-admin . If run on Windows host, bind-mount a share upload file folder at c:\myems-upload to the container and also bind-mount nginx.conf -v parameter for upload folder must be same with that in myems-api ```bash -docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/html/admin/upload -v c:\myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin +docker run -d -p 8001:8001 -v c:\myems-upload:/var/www/myems-admin/upload -v c:\myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin ``` If run on Linux host, bind-mount a share upload file folder at /myems-upload to the container and also bind-mount nginx.conf ```bash -docker run -d -p 8001:8001 -v /myems-upload:/var/www/html/admin/upload -v /myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin +docker run -d -p 8001:8001 -v /myems-upload:/var/www/myems-admin/upload -v /myems-admin/nginx.conf:/etc/nginx/nginx.conf --restart always --name myems-admin myems/myems-admin ``` -d Run container in background and print container ID @@ -96,13 +96,13 @@ http{ } ``` -Add a new 'server' section with direstives as below: +Add a new 'server' section with directives as below: ``` server { listen 8001; server_name myems-admin; location / { - root /var/www/html/admin; + root /var/www/myems-admin; index index.html index.htm; } ## To avoid CORS issue, use Nginx to proxy myems-api to path /api @@ -120,19 +120,18 @@ Add a new 'server' section with direstives as below: If the server can not connect to the internet, please compress the myems/myems-admin folder and upload it to the server and extract it to ~/myems/myems-admin ```bash sudo mkdir /var/www -sudo mkdir /var/www/html -sudo cp -r myems/myems-admin /var/www/html/admin -sudo chmod 0755 -R /var/www/html/admin +sudo cp -r myems/myems-admin /var/www/myems-admin +sudo chmod 0755 -R /var/www/myems-admin ``` Check the config file and change it if necessary: ```bash -sudo nano /var/www/html/admin/app/api.js +sudo nano /var/www/myems-admin/app/api.js ``` ## NOTE: The 'upload' folder is for user uploaded files. DO NOT delete/move/overwrite the 'upload' folder when you upgraded myems-admin. ```bash - /var/www/html/admin/upload + /var/www/myems-admin/upload ``` @@ -156,9 +155,9 @@ Add a new 'VirtualHost' as below ```xml ServerAdmin MyEMS-admin - DocumentRoot /var/www/admin + DocumentRoot /var/www/myems-admin - + Options FollowSymLinks AllowOverride All Require all granted @@ -171,12 +170,12 @@ Add a new 'VirtualHost' as below * Install myems-admin : If the server can not connect to the internet, please compress the myems/myems-admin folder and upload it to the server and extract it to ~/myems/myems-admin ```bash -sudo cp -r myems/myems-admin /var/www/html/admin -sudo chmod 0755 -R /var/www/html/admin +sudo cp -r myems/myems-admin /var/www/myems-admin +sudo chmod 0755 -R /var/www/myems-admin ``` Check the config file and change it if necessary: ```bash -sudo nano /var/www/html/admin/app/api.js +sudo nano /var/www/myems-admin/app/api.js ``` diff --git a/myems-admin/nginx.conf b/myems-admin/nginx.conf index 1de6c8a0..97b0e036 100644 --- a/myems-admin/nginx.conf +++ b/myems-admin/nginx.conf @@ -32,7 +32,7 @@ http { #access_log /var/log/nginx/host.access.log main; location / { - root /var/www/html/admin; + root /var/www/myems-admin; index index.html index.htm; } @@ -42,7 +42,7 @@ http { # error_page 500 502 503 504 /50x.html; location = /50x.html { - root /var/www/html/admin; + root /var/www/myems-admin; } location /api { diff --git a/myems-web/Dockerfile b/myems-web/Dockerfile index a0641776..d64289b7 100644 --- a/myems-web/Dockerfile +++ b/myems-web/Dockerfile @@ -4,10 +4,10 @@ FROM nginx:latest RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf # create new root folder -RUN mkdir -p /var/www/html/web +RUN mkdir -p /var/www/myems-web # Note: You should run 'npm run build' in the web direction to generate the production build. COPY nginx.conf /etc/nginx/ -COPY ./build/ /var/www/html/web +COPY ./build/ /var/www/myems-web EXPOSE 80 CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"] \ No newline at end of file diff --git a/myems-web/README.md b/myems-web/README.md index 61ee91bc..75c7442f 100644 --- a/myems-web/README.md +++ b/myems-web/README.md @@ -1,8 +1,8 @@ # myems-web ## Introduction -MyEMS Web 用户界面,用于查询能源报表 -Providing Web UI of MyEMS for viewing energy reports +Web 用户界面,用于能源数据可视化 +Providing Web UI for energy data visualization ## Prerequisites @@ -22,7 +22,7 @@ sudo ln -s /usr/local/lib/nodejs/node-vxx.x.x-linux-x64/bin/node /usr/bin/node sudo ln -s /usr/local/lib/nodejs/node-vxx.x.x-linux-x64/bin/npm /usr/bin/npm sudo ln -s /usr/local/lib/nodejs/node-vxx.x.x-linux-x64/bin/npx /usr/bin/npx ``` -Download Latest Current Version Windows Installer (.msi) 64-bit from https://nodejs.org/en/download/current/ +Download the latest current version Windows installer (.msi) 64-bit from https://nodejs.org/en/download/current/ Install Node.js with Setup Wizard @@ -147,13 +147,13 @@ http{ } ``` -Add a new 'server' section with direstives as below: +Add a new 'server' section with directives as below: ``` server { listen 80; server_name myems-web; location / { - root /var/www/html/web; + root /var/www/myems-web; index index.html index.htm; # add try_files directive to avoid 404 error while refreshing pages try_files $uri /index.html; @@ -190,8 +190,8 @@ tar czvf myems-web.tar.gz build Note that the following path should be same as that was configured in nginx.conf. ```bash tar xzf myems-web.tar.gz -sudo rm -r /var/www/html/web -sudo mv build /var/www/html/web +sudo rm -r /var/www/myems-web +sudo mv build /var/www/myems-web ``` ### Option 3: Install on Apache2 Server @@ -214,9 +214,9 @@ Add a new 'VirtualHost' as below ``` ServerAdmin MyEMS-web - DocumentRoot /var/www/web + DocumentRoot /var/www/myems-web - + Options FollowSymLinks AllowOverride All Require all granted @@ -244,12 +244,12 @@ tar czvf myems-web.tar.gz build Note that the following path should be same as that was configured in 000-default.conf ```bash tar xzf myems-web.tar.gz -sudo rm -r /var/www/web -sudo mv build /var/www/web +sudo rm -r /var/www/myems-web +sudo mv build /var/www/myems-web ``` * avoid 404 error while refreshing pages ```bash -cd /var/www/web +cd /var/www/myems-web sudo vi .htaccess ``` Add a IfModule as below: diff --git a/myems-web/nginx.conf b/myems-web/nginx.conf index e841df22..1aa5df29 100644 --- a/myems-web/nginx.conf +++ b/myems-web/nginx.conf @@ -31,7 +31,7 @@ http { #access_log /var/log/nginx/host.access.log main; location / { - root /var/www/html/web; + root /var/www/myems-web; index index.html index.htm; # add try_files directive to avoid 404 error while refreshing pages try_files $uri /index.html; @@ -43,7 +43,7 @@ http { # error_page 500 502 503 504 /50x.html; location = /50x.html { - root /var/www/html/web; + root /var/www/myems-web; } location /api {