Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Nginx+Tomcat multi-site

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Nginx+Tomcat multi-site deployment", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Nginx+Tomcat multi-site deployment" this article.

Tomcat configuration:

Add multiple domain names:

Under the Engine node:

Add Domain name 1

Add Domain name 2

Note that you also need a default statement, that is, the domain name of name= "localhost", otherwise tomcat will occasionally report null pointer errors, resulting in failure to use

At this point, the configuration is complete and restart tomcat:

Sudo / etc/init.d/tomcat8 stopsudo / etc/init.d/tomcat8 start

Or

Sudo / etc/init.d/tomcat8 restart

If the domain name resolution is complete, it can be tested in the browser.

Http://test1.java.com:8080

Http://test2.java.com:8080

If correct, it can be accessed normally.

Configure Nginx

Enter the Nginx root directory (subject to ubuntu 16.04)

Cd / etc/nginx

Enter the sites-available directory

Cd sites-available

Create a configuration file (test1.java.com as an example)

Vi test1.java.com

Enter configuration content

Server {listen 80; server_name test1.java.com; server_name_in_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / {proxy_pass http://test1.java.com:8080;}}

After esc: save by wq

The creation of a soft connection has been used

Ln-s / etc/nginx/sites-available/test1.java.com / etc/nginx/sites-enabled/test1.java.com

Restart Nginx

/ etc/init.d/nginx stop/etc/init.d/nginx start or / etc/init.d/nginx restart are all the contents of the article "how to deploy Nginx+Tomcat multiple sites". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report