Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)

Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)

1. Package the Java project into a jar package

Here I use the Maven tool

There are two projects here. After packaging, one is demo.jar and the other is jst.jar

2. Prepare tools

1. Server
2. Domain name (Note: after filing)
3. Xshell is used to connect to the server
4. WinScp (Note: View tool, used to transfer jar)

3. Transfer the jar package to the server

insert image description here

Just drag

3. Use Xshell to run the jar package

Note: (Please configure the server's Java environment and Maven environment by yourself, which will not be described here.)

insert image description here

cd to the jar package path and execute: nohup java -jar demo.jar >temp.txt &
After executing and starting the two jar packages, use the ip and port number to access the interface

insert image description here

(Note: test interface)

4. Download and install nginx

Installation Tutorial

5. Configure nginx.conf

**(Note: ********* represents the server address)

http {
 include mime.types;
 default_type application/octet-stream;

 #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
 # '$status $body_bytes_sent "$http_referer" '
 # '"$http_user_agent" "$http_x_forwarded_for"';

 #access_log logs/access.log main;

 sendfile on;
 #tcp_nopush on;

 #keepalive_timeout 0;
 keepalive_timeout 65;

 #gzip on;
 
 server {
  #Listening port number listen 80;
  #Set the secondary domain name to be accessed server_name demo.eysource.com;

  #charset koi8-r;

  #access_log logs/host.access.log main;

  location /{
  #Configure the project path to access (Note: This is the key point)
  proxy_pass http:********:9091/
  #root html;
  # index index.html index.htm;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size 100m;
  root html;
  index index.html index.htm;
   }
  }
 server {
  #Listening port number listen 80;
  #Set the secondary domain name to be accessed server_name aaa.eysource.com;

  #charset koi8-r;

  #access_log logs/host.access.log main;

  location /{
  #Configure the project path to access (Note: This is the key point)
  proxy_pass http:********:8080/
  #root html;
  # index index.html index.htm;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  client_max_body_size 100m;
  root html;
  index index.html index.htm;
   }
  }
 }

6Access by domain name (successful)

insert image description here

Summarize

This is the end of this article about the detailed tutorial (jar package) on how to deploy Springboot projects using Nginx on servers. For more information about Springboot project deployment on servers, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Complete steps for deploying a front-end and back-end separated nginx configuration
  • Detailed explanation of Nginx server setup and basic configuration
  • Nginx Location Configuration Tutorial from Scratch
  • Detailed tutorial on how to start nginx configuration service
  • Even a novice can complete the deployment of Nginx service with zero foundation

<<:  MySQL 8.0.20 installation and configuration tutorial under Docker

>>:  vue3.0+echarts realizes three-dimensional column chart

Recommend

A brief analysis of the knowledge points of exporting and importing MySQL data

Often, we may need to export local database data ...

MySQL uses inet_aton and inet_ntoa to process IP address data

This article will introduce how to save IP addres...

Mini Program Custom TabBar Component Encapsulation

This article example shares the specific code for...

js canvas realizes circular water animation

This article example shares the specific code of ...

VMware15/16 Detailed steps to unlock VMware and install MacOS

VMware version: VMware-workstation-full-16 VMware...

Vue3 draggable left and right panel split component implementation

Table of contents Breaking down components Left P...

Detailed example of SpringBoot+nginx to achieve resource upload function

Recently, I have been learning to use nginx to pl...

CSS3 to achieve floating cloud animation

Operation effect html <head> <meta chars...

How to calculate the frame rate FPS of web animations

Table of contents Standards for smooth animation ...

Collection of 25 fonts used in famous website logos

This article collects the fonts used in the logos...

How to create a MySQL master-slave database using Docker on MacOS

1. Pull the MySQL image Get the latest MySQL imag...

select the best presets to create full compatibility with all browsersselect

We know that the properties of the select tag in e...

Ubuntu 15.04 opens mysql remote port 3306

Ubuntu 15.04 opens MySQL remote port 3306. All th...