If the framework is deployed separately from the front and back end projects (JAR package +Nginx deployment)

Recently, I did a small project with Roy’s front and back end separation framework. I had some problems when I wanted to deploy to another Windows PC (server). Finally, I solved it and wrote a document summarizing it.

1. Mandatory deployment

To deploy the project to a server, the server must have the following conditions: 1.JDK1.8 or above 2.Tomact (not required if jar packages are deployed) 3

Pack 2.

For this step, please refer to the documentation provided on the official website, where I indicate the parts I have implemented

2.1 Background Packaging

If you need to package to Tomact, change packaging in Ruoyi/Pom.xml to WAR, which uses jar packages, so you don’t need to change.Then you can package it via Maven.

2.2 Front-end Packaging

Enter the package command on the console

NPM run build:prod # NPM run build:stageCopy the code

After typing, a folder named dist is generated

Deployment of 3.

Step 1: Start the database. Exe redis.windows.conf, redis.server.exe redis.windows.conf, redis.server.exe, redis.windows.conf, redis.server.exe Run the backend JAR package (or Tomact deployment WAR package).

Key start:Step 4: Configure Nginx. First, put the newly typed front-end package (dist folder) into the HTML folder in Nginx.Then go back one layer to conf to modify the nginx configuration fileMy modification is as follows, delete the comment when copying:

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       90;// Front-end project port
        server_name  localhost;
        location / {
        root   html/dist;// The path just held
        index  index.html index.htm;
        }
		
      location /prod-api/{
      	proxy_set_header Host $http_host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header REMOTE-HOST $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_pass http://localhost:8090/; // The running port of the background project
}

        error_page   500 502 503 504/50x.html; location = /50x.html { root html; }}}Copy the code

Once that’s done, run Nginx and access the front-end port (90).