Nginx, pm2 finishing

Common commands

nginx
nginx -s reload

content

  • /etc/nginx/sites-availableStore website configuration links
  • sites-enabledStore website configuration
  • ln -s /etc/nginx/sites-available/education /etc/nginx/sites-enabled/educationgenerate link
  • /etc/nginx/certStore certificate (custom)

configure

# http 跳转到 https
server {
  listen 80;
  server_name edu.qushen.net;
  rewrite ^(.*)$ https://$host$1 permanent;
}

server {
  listen 80;
  server_name admin.edu.qushen.net;
  rewrite ^(.*)$ https://$host$1 permanent;
}

# 以下属性中以ssl开头的属性代表与证书配置有关,其他属性请根据自己的需要进行配置。
server {
  listen 443 ssl; #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
  server_name edu.qushen.net; #将localhost修改为您证书绑定的域名,例如:www.example.com。
  ssl_certificate cert/education/3541609_edu.qushen.net.pem; #将domain name.pem替换成您证书的文件名。
  ssl_certificate_key cert/education/3541609_edu.qushen.net.key; #将domain name.key替换成您证书的密钥文件名。
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
  ssl_prefer_server_ciphers on;

  location / {
    root /var/www/education/web/dist;
    try_files $uri $uri/ /index.html;
  }
}

server {
  listen 443 ssl; #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
  server_name admin.edu.qushen.net; #将localhost修改为您证书绑定的域名,例如:www.example.com。
  ssl_certificate cert/education/3612755_admin.edu.qushen.net.pem; #将domain name.pem替换成您证书的文件名。
  ssl_certificate_key cert/education/3612755_admin.edu.qushen.net.key; #将domain name.key替换成您证书的密钥文件名。
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
  ssl_prefer_server_ciphers on;

  location / {
    root /var/www/education/frontend/dist;
    try_files $uri $uri/ /index.html;
  }
}


server {
  listen 443 ssl; #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
  server_name api.edu.qushen.net; #将localhost修改为您证书绑定的域名,例如:www.example.com。
  ssl_certificate cert/education/3543472_api.edu.qushen.net.pem; #将domain name.pem替换成您证书的文件名。
  ssl_certificate_key cert/education/3543472_api.edu.qushen.net.key; #将domain name.key替换成您证书的密钥文件名。
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #使用此加密套件。
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
  ssl_prefer_server_ciphers on;

  location / {
    proxy_pass http://127.0.0.1:7001;
  }
}

Vue project configuration subdirectory

Modify routing index.js:

Modify vue.config.js:

The deployment folder is created according to the subdirectory structure, such as:

Pay attention to the writing method of the secondary directory, such as the following client

server {
  listen 80;
  server_name gaoduanjiyou.audihd.net;

  location / {
    root /var/www/new_write_off_system/client/agent;
    try_files $uri $uri/ /index.html;
  }
  location /h5/ {
    root /var/www/new_write_off_system/client/;
    try_files $uri $uri/ /h5/index.html;
  }
  
  location /admin/ {
    root /var/www/new_write_off_system/frontend/;
    try_files $uri $uri/ /admin/index.html;
  }

  location /backend/ {
    proxy_pass http://127.0.0.1:7002/;
    proxy_set_header Host $host:$server_port;
  }
}


Nuxt.js project + Vue project + Egg.js project

map $sent_http_content_type $expires {
  "text/html" epoch;
  "text/html; charset=utf-8" epoch;
  default off;
}

server {
  listen 80;
  server_name game.qushen.net;

  gzip on;
  gzip_types text/plain application/xml text/css application/javascript;
  gzip_min_length 1000;

  location / {
    expires $expires;

    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 1m;
    proxy_connect_timeout 1m;
    proxy_pass http://127.0.0.1:3000; # set the address of the Node.js instance here
  }

  location /admin {
    root /var/www/game/frontend/;
    try_files $uri $uri/ /admin/index.html;
  }

  location /backend/ {
    proxy_pass http://127.0.0.1:7003/;
    proxy_set_header Host $host:$server_port;
  }
}

pm2 starts the nuxt project

cd to the project directory (note: --name has no spaces)

  • pm2 start npm --name "game" -- run start
{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324148252&siteId=291194637