updated nginx configs for myems-admin and myems-web

pull/135/head
13621160019@163.com 2022-03-17 22:38:07 +08:00
parent 8446818f2d
commit 646295363a
9 changed files with 36 additions and 35 deletions

View File

@ -230,4 +230,5 @@ administrator@myems.io
## QQ交流群 ## QQ交流群
群号: 792528967 群号: 792528967
![QQ群](/docs/images/qq-group.png) ![QQ群](/docs/images/qq-group.png)

View File

@ -226,4 +226,5 @@ Sehen [Kooperationsplan für Integrationstests](integration-testing-cn.md)
## QQ-Gruppe ## QQ-Gruppe
Gruppennummer: 792528967 Gruppennummer: 792528967
![QQ Group 1](/docs/images/qq-group-1.png) ![QQ Group 1](/docs/images/qq-group-1.png)

View File

@ -228,4 +228,5 @@ See [Integration Testing Cooperation Plan](integration-testing-cn.md)
## QQ Group ## QQ Group
Group Number: 792528967 Group Number: 792528967
![QQ Group 1](/docs/images/qq-group-1.png) ![QQ Group 1](/docs/images/qq-group-1.png)

View File

@ -5,11 +5,10 @@ RUN rm /etc/nginx/conf.d/default.conf && \
rm /etc/nginx/nginx.conf rm /etc/nginx/nginx.conf
# create new root folder # create new root folder
# todo: share upload folder in admin with myems-api container on Docker RUN mkdir -p /var/www/myems-admin
RUN mkdir -p /var/www/html/admin
# copy the config and web codes # copy the config and web codes
COPY nginx.conf /etc/nginx/ COPY nginx.conf /etc/nginx/
COPY . /var/www/html/admin COPY . /var/www/myems-admin
EXPOSE 8001 EXPOSE 8001
CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"] CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]

View File

@ -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 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 -v parameter for upload folder must be same with that in myems-api
```bash ```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 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 ```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 -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 { server {
listen 8001; listen 8001;
server_name myems-admin; server_name myems-admin;
location / { location / {
root /var/www/html/admin; root /var/www/myems-admin;
index index.html index.htm; index index.html index.htm;
} }
## To avoid CORS issue, use Nginx to proxy myems-api to path /api ## 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 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 ```bash
sudo mkdir /var/www sudo mkdir /var/www
sudo mkdir /var/www/html sudo cp -r myems/myems-admin /var/www/myems-admin
sudo cp -r myems/myems-admin /var/www/html/admin sudo chmod 0755 -R /var/www/myems-admin
sudo chmod 0755 -R /var/www/html/admin
``` ```
Check the config file and change it if necessary: Check the config file and change it if necessary:
```bash ```bash
sudo nano /var/www/html/admin/app/api.js sudo nano /var/www/myems-admin/app/api.js
``` ```
## NOTE: ## NOTE:
The 'upload' folder is for user uploaded files. DO NOT delete/move/overwrite the 'upload' folder when you upgraded myems-admin. The 'upload' folder is for user uploaded files. DO NOT delete/move/overwrite the 'upload' folder when you upgraded myems-admin.
```bash ```bash
/var/www/html/admin/upload /var/www/myems-admin/upload
``` ```
@ -156,9 +155,9 @@ Add a new 'VirtualHost' as below
```xml ```xml
<VirtualHost 127.0.0.1:8001> <VirtualHost 127.0.0.1:8001>
ServerAdmin MyEMS-admin ServerAdmin MyEMS-admin
DocumentRoot /var/www/admin DocumentRoot /var/www/myems-admin
<Directory "var/www/admin"> <Directory "var/www/myems-admin">
Options FollowSymLinks Options FollowSymLinks
AllowOverride All AllowOverride All
Require all granted Require all granted
@ -171,12 +170,12 @@ Add a new 'VirtualHost' as below
* Install myems-admin : * 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 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 ```bash
sudo cp -r myems/myems-admin /var/www/html/admin sudo cp -r myems/myems-admin /var/www/myems-admin
sudo chmod 0755 -R /var/www/html/admin sudo chmod 0755 -R /var/www/myems-admin
``` ```
Check the config file and change it if necessary: Check the config file and change it if necessary:
```bash ```bash
sudo nano /var/www/html/admin/app/api.js sudo nano /var/www/myems-admin/app/api.js
``` ```

View File

@ -32,7 +32,7 @@ http {
#access_log /var/log/nginx/host.access.log main; #access_log /var/log/nginx/host.access.log main;
location / { location / {
root /var/www/html/admin; root /var/www/myems-admin;
index index.html index.htm; index index.html index.htm;
} }
@ -42,7 +42,7 @@ http {
# #
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;
location = /50x.html { location = /50x.html {
root /var/www/html/admin; root /var/www/myems-admin;
} }
location /api { location /api {

View File

@ -4,10 +4,10 @@ FROM nginx:latest
RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf RUN rm /etc/nginx/conf.d/default.conf && rm /etc/nginx/nginx.conf
# create new root folder # 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. # Note: You should run 'npm run build' in the web direction to generate the production build.
COPY nginx.conf /etc/nginx/ COPY nginx.conf /etc/nginx/
COPY ./build/ /var/www/html/web COPY ./build/ /var/www/myems-web
EXPOSE 80 EXPOSE 80
CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"] CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]

View File

@ -1,8 +1,8 @@
# myems-web # myems-web
## Introduction ## Introduction
MyEMS Web 用户界面,用于查询能源报表 Web 用户界面,用于能源数据可视化
Providing Web UI of MyEMS for viewing energy reports Providing Web UI for energy data visualization
## Prerequisites ## 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/npm /usr/bin/npm
sudo ln -s /usr/local/lib/nodejs/node-vxx.x.x-linux-x64/bin/npx /usr/bin/npx 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 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 { server {
listen 80; listen 80;
server_name myems-web; server_name myems-web;
location / { location / {
root /var/www/html/web; root /var/www/myems-web;
index index.html index.htm; index index.html index.htm;
# add try_files directive to avoid 404 error while refreshing pages # add try_files directive to avoid 404 error while refreshing pages
try_files $uri /index.html; 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. Note that the following path should be same as that was configured in nginx.conf.
```bash ```bash
tar xzf myems-web.tar.gz tar xzf myems-web.tar.gz
sudo rm -r /var/www/html/web sudo rm -r /var/www/myems-web
sudo mv build /var/www/html/web sudo mv build /var/www/myems-web
``` ```
### Option 3: Install on Apache2 Server ### Option 3: Install on Apache2 Server
@ -214,9 +214,9 @@ Add a new 'VirtualHost' as below
``` ```
<VirtualHost 127.0.0.1:80> <VirtualHost 127.0.0.1:80>
ServerAdmin MyEMS-web ServerAdmin MyEMS-web
DocumentRoot /var/www/web DocumentRoot /var/www/myems-web
<Directory "var/www/web"> <Directory "var/www/myems-web">
Options FollowSymLinks Options FollowSymLinks
AllowOverride All AllowOverride All
Require all granted 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 Note that the following path should be same as that was configured in 000-default.conf
```bash ```bash
tar xzf myems-web.tar.gz tar xzf myems-web.tar.gz
sudo rm -r /var/www/web sudo rm -r /var/www/myems-web
sudo mv build /var/www/web sudo mv build /var/www/myems-web
``` ```
* avoid 404 error while refreshing pages * avoid 404 error while refreshing pages
```bash ```bash
cd /var/www/web cd /var/www/myems-web
sudo vi .htaccess sudo vi .htaccess
``` ```
Add a IfModule as below: Add a IfModule as below:

View File

@ -31,7 +31,7 @@ http {
#access_log /var/log/nginx/host.access.log main; #access_log /var/log/nginx/host.access.log main;
location / { location / {
root /var/www/html/web; root /var/www/myems-web;
index index.html index.htm; index index.html index.htm;
# add try_files directive to avoid 404 error while refreshing pages # add try_files directive to avoid 404 error while refreshing pages
try_files $uri /index.html; try_files $uri /index.html;
@ -43,7 +43,7 @@ http {
# #
error_page 500 502 503 504 /50x.html; error_page 500 502 503 504 /50x.html;
location = /50x.html { location = /50x.html {
root /var/www/html/web; root /var/www/myems-web;
} }
location /api { location /api {