Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to access a project on tomcat without adding a project name or 8080 port number

Shulou Source: shulou.com Published: 2022-06-02 10:12:40 10月02日 Update

This article mainly explains "how to access projects on tomcat without adding project name or 8080 port number". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to access projects on tomcat without adding a project name or 8080 port number.

1. How to access the project on tomcat only through IP address or domain name without adding the project name

First open the server.xml file of tomcat (those who are not familiar with vi operation can learn)

Vi wocloud/apache-tomcat-9.0.19/conf/server.xml

Find the following paragraph

Add at the end

Just restart Tomcat.

two。 How to access the server directly through the ip address or domain name without adding the port number 8080

Reason: apache is deployed under Linux. For security, we use non-root users to launch, but the 80 port number cannot be accessed directly when the domain name is bound. As we all know, under unix, non-root users cannot listen to port numbers below 1024, and the apache server cannot be bound under port 80. Therefore, we need to use linux's port forwarding mechanism to transfer all service requests to port 80 to port 8080.

What should we do? Just run the command under your root account:

Iptables-t nat-A PREROUTING-p tcp-- dport 80-j REDIRECT-- to-port 8080

Transfer all service requests to port 80 to port 8080.

In addition, if the firewall is restarted, the command will fail, and you can use the following command to save the rule to iptables.

Service iptables save so far, I believe you have a deeper understanding of "how to access projects on tomcat without adding a project name or 8080 port number". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Project slogan port service command domain name learning content address server user practical deeper secure well-known interest method reason practical practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Shulou Technology Apple Xiaomi