Details of Nginx+Tomcat+Https server load balancing configuration practices
- 2020-05-12 06:51:03
- OfStack
Because of the need, we have to set up a server of nginx+tomcat+https. After searching the net, we always find some mistakes. Now we have sorted out some useful memos.
Environment: Centos6.5, JDK1.8, Tomcat8, Nginx1.10.1
Preparation materials:
1. JDK1.8 installation package jdk-8u102-linux-x64.tar.gz
2.Tomcat8 installation package apache-tomcat-8.0.37. tar.gz
3. Nginx1.10 installation package nginx-1.10.1.tar.gz
1. JDK installation configuration
Unzip and install to /usr/local/jdk
[root@localhost ~]# tar zxvf jdk-8u102-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_102 /usr/local/jdk
Configure the JDK environment variable
[root@localhost ~]# vi /etc/profile
Add the following at the bottom
JAVA_HOME=/usr/local/jdk
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME JRE_HOME PATH CLASSPATH
Application environment variables
[root@localhost ~]# source /etc/profile
Check for success and display the version indicating success
[root@localhost ~]# java -version
2. Installation and configuration of Tomcat
Unzip and install to /usr/local/tomcat
[root@localhost ~]# tar zxvf apache-tomcat-8.0.37.tar.gz
[root@localhost ~]# mv apache-tomcat-8.0.37 /usr/local/tomcat
By default tomcat is run with root identity, which is not secure. Here, normal users are set to run
[root@localhost ~]# groupadd tomcat
[root@localhost ~]# useradd -g tomcat tomcat
[root@localhost ~]# passwd tomcat
[root@localhost ~]# chown tomcat.tomcat -R /usr/local/tomcat
Run tomcat
[root@localhost ~]# su - tomcat /usr/local/tomcat/bin/startup.sh
Set to boot
[root@localhost ~]# echo "su - tomcat /usr/local/tomcat/bin/startup.sh" >> /etc/rc.local
3. Installation and configuration of Nginx
Configure the Nginx user
[root@localhost ~]# groupadd nginx
[root@localhost ~]# useradd -g nginx -s /sbin/nologin nginx
Install dependency package
[root@localhost ~]# vi /etc/profile
0
Unzip and enter the folder
[root@localhost ~]# vi /etc/profile
1
Configure the installation
[root@localhost ~]# vi /etc/profile
2
Configuration Nginx
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf
This step 1 will need to manually ssl certificates in a/usr/local/nginx conf/directory, cert respectively. crt and cert key file
If the certificate file is in a different format, you can search for the conversion method yourself
If you do not need to configure https, change port 443
nginx master configuration file
[root@localhost ~]# vi /etc/profile
4
Start the server
[root@localhost ~]# vi /etc/profile
5
Browser access is successful when a kitten appears.