1. For the locally developed demo program, under the target directory, type all the files of META-INF, WEB-INF, index.jsp into a zip package, as shown in the figure below:
2. Under the Linux server, deploy to Tomcat, clear all files in the ROOT directory, put the nginx.zip file in 1 in the ROOT directory, after decompression, switch to
In the Tomcat bin directory, start Tomcat. Turn off the firewall, the outside can be accessed through port: IP.
-
# 解压
-
[root@localhost ROOT]# unzip nginx.zip
-
[root@localhost ROOT]# /opt/apache-tomcat-8.5.34/webapps/ROOT
-
[root@localhost ROOT]# ls
-
index.jsp META-INF nginx.zip WEB-INF
-
# bin下 启动Tomcat
-
[root@localhost bin]# ./startup.sh
3. Install nginx, refer to nginx installation configuration
Installation directory: /usr/local/nginx
4. Configure nginx for domain name access
-
[root@localhost conf]# pwd
-
/usr/local/nginx/conf
-
[root@localhost conf]# cat -n nginx.conf
5. Attach the main configuration code configuration
#gzip on;
upstream testnginx{
server localhost:8080;
#server localhost:8081;
}
server {
listen 80;
server_name www.testnginx.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://testnginx;
#proxy_pass http://localhost:8080;
#proxy_set_header Host $http_host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#index index.html index.htm;
}
#error_page 404 /404.html;
6. Modify the configuration and reload nginx
-
[root@localhost sbin]# pwd
-
/usr/local/nginx/sbin
-
[root@localhost sbin]# ./nginx -s reload
7. Because there is no unified DNS settings (generally companies have, you can do unified resolution), so you need to modify the local host file as follows to do domain name IP mapping. Because the DNS of the external network cannot resolve the domain name www.testnginx.com configured by nginx above, it cannot be requested. The host configuration is as follows:
-
host路径: C:\Windows\System32\drivers\etc
-
文件内容: 192.168.85.128 www.testnginx.com
8. The results of the interview are as follows: