programing tip

Tomcat 포트를 8080에서 80으로 변경하는 방법은 무엇입니까?

itbloger 2020. 6. 9. 08:16
반응형

Tomcat 포트를 8080에서 80으로 변경하는 방법은 무엇입니까?


웹 앱을으로 실행하고 싶습니다 http://localhost.


1) confTomcat 설치 디렉토리의 폴더로 이동

 e.g. C:\Tomcat 6.0\conf\

2) 파일 에서 다음 태그 편집server.xml

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

3) port=8080값을port=80

4) 파일을 저장하십시오.

5) Tomcat을 중지하고 다시 시작하십시오.


Amazon EC2의 Ubuntu 14.04 LTS 다음 단계로이 문제가 해결되었습니다.

1. server.xml을 편집하고 port = "8080"을 "80"으로 변경하십시오.

sudo vi /var/lib/tomcat7/conf/server.xml

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

2. tomcat7 파일을 편집하십시오 (파일이 작성되지 않은 경우 작성해야 함).

sudo vi /etc/default/tomcat7

주석을 해제하고 # AUTHBIND = no를 yes로 변경하십시오.

3. authbind 설치

sudo apt-get install authbind

4. 다음 명령을 실행하여 포트 80에서 tomcat7 읽기 + 실행을 제공하십시오.

sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80

5. 바람둥이를 다시 시작하십시오 :

sudo /etc/init.d/tomcat7 restart

Linux 데비안 기반 (따라서 우분투 포함) 에서는 서버가 권한있는 포트에서 바인딩되도록 행을 /etc/default/tomcat7주석 해제 #AUTHBIND=no하고 값을 'yes'로 설정해야합니다.


우분투 및 데비안 시스템에는 몇 가지 단계가 필요합니다.

  1. server.xml에서 행 <Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>을로 변경하십시오 port="80".

  2. 다음과 같은 명령을 사용하여 권장 (필요하지 않은) authbind 패키지를 설치하십시오.

    sudo apt-get install authbind

  3. 주석을 해제하고 다음과 같이 행을 설정하여 server.xml 파일에서 /etc/tomcat6또는으로 authbind를 사용하십시오 /etc/tomcat7.

    AUTHBIND=yes

세 단계가 모두 필요합니다.


나는에서 포트를 변경 시도 808080server.xml있지만 나를 위해 작동하지 않았다. 그런 다음 대안을 찾았 iptables습니다. 성능에 영향을 줄 것으로 확신하는 업데이트 하십시오.

다음 명령을 사용합니다.

sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo /sbin/service iptables save

http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html#port80


14.04 Ubuntu Server에서 이전 답변이 제대로 작동하지 않았지만 (충분하지는 않았지만) 권장 사항에 대해 언급 했습니다 (견적입니다).

편집 : @ jason-faust가 주석에서 언급했듯이 14.04에서 authbind패키지와 함께 제공 되는 패키지는 현재 IPv6을 지원하므로 IPv4를 선호하는 것은 더 이상 필요하지 않습니다 .

1) Install authbind
2) Make port 80 available to authbind (you need to be root):

  touch /etc/authbind/byport/80
  chmod 500 /etc/authbind/byport/80
  chown tomcat7 /etc/authbind/byport/80

3) Make IPv4 the default (authbind does not currently support IPv6).
   To do so, create the file TOMCAT/bin/setenv.sh with the following content: 

   CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"

4) Change /usr/share/tomcat7/bin/startup.sh

  exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@"
  # OLD: exec "$PRGDIR"/"$EXECUTABLE" start "$@"

당신이 이미 가지고있는 경우 setenv.sh에 파일 /usr/share/tomcat7/bin과를 CATALINA_OPTS, 당신은 사용해야합니다 :

export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"

이제 80다른 답변에서 설명한대로 포트를 변경할 수 있습니다 .


현대 리눅스에서 가장 좋은 방법은 xinetd를 사용하는 것입니다.

1) /etc/xinet.d/tomcat-http를 만듭니다.

service http
{
        disable = no
        socket_type = stream
        user = root
        wait = no
        redirect = 127.0.0.1 8080
}

2) /etc/xinet.d/tomcat-https를 만듭니다.

service https
{
        disable = no
        socket_type = stream
        user = root
        wait = no
        redirect = 127.0.0.1 8443
}

3) chkconfig xinetd 켜기

4) /etc/init.d/xinetd 시작


If someone is looking for, how to change the tomcat port number in Eclipse IDE user following are the steps.

1.In the Servers view, double click on the server name: enter image description here

2.That will open a configuration page for Tomcat as follows: enter image description here

3.Notice the port numbers are shown in the table on the right. Click to edit, for example: enter image description here

4.That will change port number for HTTP from 8080 to 80. Press Ctrl + S to save the change and restart the server. We can spot the change of port number in the Console view: enter image description here

This all content were taken from below link, please refer that link for further information thanks. http://www.codejava.net/servers/tomcat/how-to-change-port-numbers-for-tomcat-in-eclipse


Running the command below worked with. Tried changing server.xml and the conf file but both didn't work.

/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

/sbin/iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT

/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080


if you are using eclipse and modifying server.xml doesn't work for you then try following article.. they have steps to modify port if you are using IDE like eclipse.


Just goto conf folder of tomcat

open the server.xml file

Goto one of the connector node which look like the following

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />

Simply change the port

save and restart tomcat


Here are the steps:

--> Follow the path: {tomcat directory>/conf -->Find this line:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

change portnumber from "8080" to "80".

--> Save the file.

--> Restart the server :)


On a linux server you can just use this commands to reconfigure Tomcat to listen on port 80:

sed -i 's|port="8080"|port="80"|g' /etc/tomcat?/server.xml
sed -i 's|#AUTHBIND=no|AUTHBIND=yes|g' /etc/default/tomcat?
service tomcat8 restart

Don't forget to edit the file. Open file /etc/default/tomcat7 and change

#AUTHBIND=no

to

AUTHBIND=yes

then restart.

참고URL : https://stackoverflow.com/questions/4756039/how-to-change-the-port-of-tomcat-from-8080-to-80

반응형