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

VSCode configuration Git method steps

Git is integrated in vscode, and many operations ...

jQuery realizes dynamic particle effect

This article shares the specific code of jQuery t...

How to modify the default storage engine in MySQL

mysql storage engine: The MySQL server adopts a m...

Comparing the performance of int, char, and varchar in MySQL

There are many seemingly true "rumors" ...

Detailed explanation of monitoring NVIDIA GPU usage under Linux

When using TensorFlow for deep learning, insuffic...

How to solve the mysql ERROR 1045 (28000)-- Access denied for user problem

Problem description (the following discussion is ...

Vue3 based on script setup syntax $refs usage

Table of contents 1. Vue2 syntax 2. Use of Vue3 1...

Detailed explanation of the solution to font blur when using transform in CSS3

This question is very strange, so I will go strai...

Analysis of the HTML writing style and reasons of experienced people

1. Navigation: Unordered List vs. Other Label Ele...

How to configure path alias for react scaffolding

The react version when writing this article is 16...

How to use cursor triggers in MySQL

cursor The set of rows returned by the select que...

Specific use of GNU Parallel

what is it? GNU Parallel is a shell tool for exec...

How to build a private Docker repository using Harbor

Table of contents 1. Open source warehouse manage...