Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to deploy Nginx+Tomcat multi-site

Shulou Source: shulou.com Published: 2022-06-01 13:44:45 10月30日 Update

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!

Tags: Configuration content domain name site article study help available in multiple domain names pointers files easy to understand more organization root directory browser directory knowledge editing so far Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Linux Redmi Shulou Technology OPPO Reno