nginx reverse proxy tomcat

The dsCentOS-empty virtual machine is in bridge network mode.
Username root
password root

ifconfig View the local ip 192.168.5.129

Close the firewall port
service iptables stop

//Start the mysql service
service mysql start
Use the command with a password to enter mysql
mysql -uroot -proot

// Import library
source /home/software/mysql/crm.sql;

//Delete all files under webapps
cd /home/software/tomcat7/webapps
rm -rf /home/software/tomcat7/webapps/* Type

the project into war package name For ROOT.war

//Copy ROOT.war to the linux desktop, and copy ROOT.war on the desktop to webapps
cp /root/Desktop/ROOT.war /home/software/t1/webapps

//Start tomcat
/home/software/ tomcat7/bin/startup.sh

//Check whether tomcat starts successfully
tail /home/software/tomcat7/logs/catalina.out

//Modify database connection
cd /home/software/tomcat7/webapps/ssm/WEB-INF/classes
vim jdbc.properties
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://192.168.5.129 :3306/db_crm?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root

After modification, save and exit, stop tomcat7, delete ROOT.war, restart tomcat7

//Native linux internal browser and this External window browser access address
http://192.168.5.129:8080/
sa sa Sales Supervisor

------------- -The local server implements nginx forwarding ---------------------------------
Local configuration hosts
127.0.0.1 www.ssm .com

//The configuration content in the nginx.conf file is as follows
#SSM server
server {
listen 80;
server_name www.ssm.com;
#charset koi8-r;
#access_log logs/host.access.log main;

#proxy_set_header X-Forwarded-Host $host;
#proxy_set_header X-Forwarded-Server $host;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $host;

location / {
       proxy_pass http://192.168.5.129:8080/;
       proxy_connect_timeout 600;
       proxy_read_timeout 600;
}
}

Native nginx access project
www.ssm.com

-------------- ---------------Other machines in the LAN access the projects published by the local linux server---------------------- -------
The access address of other machines in the LAN
http://192.168.5.129:8080

When other machines access www.ssm.com, you need to configure the network ip and domain name of my machine in the hosts file of other machines
ipconfig/all view the local network ip such as ip 192.168.5.131

other machines hosts file configuration
192.168.5.131 www.ssm.com

other machines nginx forwarding
#SSM server
server {
listen 80;
server_name www.ssm.com;
#charset koi8-r ;
#access_log logs/host.access.log main;

#proxy_set_header X-Forwarded-Host $host;
#proxy_set_header X-Forwarded-Server $host;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $host;

location / {
       proxy_pass http://192.168.5.131:8080/;
       proxy_connect_timeout 600;
       proxy_read_timeout 600;
}
}

Other machines start nginx browser access
www.ssm.com

Guess you like

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