From 375f94ed3af7c726b41019797aee5f0588cb31a8 Mon Sep 17 00:00:00 2001 From: "13621160019@163.com" <13621160019@163.com> Date: Sun, 21 Feb 2021 15:54:08 +0800 Subject: [PATCH] updated READMEs for using gzip on NGINX --- admin/README.md | 57 +++++++++++++++++++++++++++++++------------------ web/README.md | 45 +++++++++++++++++++++++++++++++++++++- 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/admin/README.md b/admin/README.md index febbc869..d11a10ed 100644 --- a/admin/README.md +++ b/admin/README.md @@ -21,26 +21,41 @@ refer to http://nginx.org/en/docs/install.html * Configure NGINX ``` - $ sudo nano /etc/nginx/nginx.conf +$ sudo nano /etc/nginx/nginx.conf ``` -Add another new 'server' section, add values as below: +In the 'http' section, add some directives: ``` - server { - listen 8001; - server_name myems-admin; - location / { - root /var/www/html/admin; - index index.html index.htm; - } - -- To avoid CORS issue, use Nginx to proxy myems-api to path /api - -- Add another location /api in 'server ', replace demo address http://127.0.0.1:8000/ with actual url - location /api { - proxy_pass http://127.0.0.1:8000/; - proxy_connect_timeout 75; - proxy_read_timeout 600; - send_timeout 600; - } - } +http{ + client_header_timeout 600; + client_max_body_size 512M; + gzip on; + gzip_min_length 512; + gzip_proxied any; + gzip_types *; + gzip_vary on; + ... + +} +``` + +Add a new 'server' section with direstives as below: +``` + server { + listen 8001; + server_name myems-admin; + location / { + root /var/www/html/admin; + index index.html index.htm; + } + -- To avoid CORS issue, use Nginx to proxy myems-api to path /api + -- Add another location /api in 'server ', replace demo address http://127.0.0.1:8000/ with actual url + location /api { + proxy_pass http://127.0.0.1:8000/; + proxy_connect_timeout 75; + proxy_read_timeout 600; + send_timeout 600; + } + } ``` * Download myems-admin @@ -52,12 +67,12 @@ $ git clone https://github.com/MyEMS/myems.git * Install myems-admin : If the server can not connect to the internet, please compress the myems/admin folder and upload it to the server and extract it to ~/myems/admin ``` - $ sudo cp -r ~/myems/admin /var/www/html/admin - $ sudo chmod 0755 -R /var/www/html/admin +$ sudo cp -r ~/myems/admin /var/www/html/admin +$ sudo chmod 0755 -R /var/www/html/admin ``` Check the config file and change it if necessary: ``` - $ sudo nano /var/www/html/admin/app/api.js +$ sudo nano /var/www/html/admin/app/api.js ``` ## NOTE: diff --git a/web/README.md b/web/README.md index 383a5b60..142eba33 100644 --- a/web/README.md +++ b/web/README.md @@ -39,6 +39,49 @@ You can run 'node server.js' to run the production build locally at http://local refer to http://nginx.org/en/docs/install.html +* Configure NGINX +``` +$ sudo nano /etc/nginx/nginx.conf +``` +In the 'http' section, add some directives: +``` +http{ + client_header_timeout 600; + client_max_body_size 512M; + gzip on; + gzip_min_length 512; + gzip_proxied any; + gzip_types *; + gzip_vary on; + ... + +} +``` + +Add a new 'server' section with direstives as below: +``` + server { + listen 80; + server_name myems-web; + location / { + root /var/www/html/web; + index index.html index.htm; + } + -- To avoid CORS issue, use Nginx to proxy myems-api to path /api + -- Add another location /api in 'server ', replace demo address http://127.0.0.1:8000/ with actual url + location /api { + proxy_pass http://127.0.0.1:8000/; + proxy_connect_timeout 75; + proxy_read_timeout 600; + send_timeout 600; + } + } +``` +Restart NGINX +``` +$ sudo systemctl restart nginx +``` + * Download myems: ``` $ cd ~ @@ -58,7 +101,7 @@ refer to http://nginx.org/en/docs/install.html ``` Install Upload the file myems-web.tar.gz to you web server. - Note that the following path may be different in your server. + Note that the following path shoudl be same as that in nginx.conf. ``` $ tar xzf myems-web.tar.gz $ sudo rm -r /var/www/html/web