tomcat을 설치하면 8080 포트로 기동되도록 되어 있습니다.
connector port 를 수정하면 원하는 포트로 기동이 가능 합니다.
그러나 보안을 생각하신다면 1024포트 이하에 tomcat을 올리는건 부담이죠.
그래서... 80 포트를 8080포트로 네트웍단에서 전환해주면 ... 손안대고 코푸는격 ??? 입니다.
아래 처리 스트립트 입니다. (iptables에 대한 매뉴얼을 찾아 보세요)
root@vlinux:~# iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination Chain POSTROUTING (policy ACCEPT) target prot opt source destination root@vlinux:~# root@vlinux:~# iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 root@vlinux:~# iptables -t nat -I OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 8080 root@vlinux:~# iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination REDIRECT tcp -- anywhere anywhere tcp dpt:www redir ports 8080 Chain OUTPUT (policy ACCEPT) target prot opt source destination REDIRECT tcp -- anywhere anywhere tcp dpt:www redir ports 8080 Chain POSTROUTING (policy ACCEPT) target prot opt source destination root@vlinux:~#
설정을 확인 해 봅니다. 분명 8080 포트만 listen하고 있죠... 그러나 telnet localhost 80 으로 치고 들어가면 톰캣으로 연결 됩니다.
root@vlinux:~# netstat -an Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 10.211.55.4:22 10.211.55.2:58023 ESTABLISHED tcp6 0 0 :::8009 :::* LISTEN tcp6 0 0 :::8080 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 :::8443 :::* LISTEN tcp6 0 0 127.0.0.1:8005 :::* LISTEN Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 6003 @/com/ubuntu/upstart unix 2 [ ] DGRAM 6103 @/org/kernel/udev/udevd unix 2 [ ] DGRAM 6818 /var/spool/postfix/dev/log unix 5 [ ] DGRAM 6816 /dev/log unix 2 [ ACC ] STREAM LISTENING 7329 /var/spool/postfix/var/run/saslauthd/mux unix 3 [ ] STREAM CONNECTED 8768 unix 3 [ ] STREAM CONNECTED 8767 unix 2 [ ] DGRAM 8761 unix 2 [ ] DGRAM 8444 unix 2 [ ] DGRAM 7328 unix 3 [ ] DGRAM 6135 unix 3 [ ] DGRAM 6134 unix 3 [ ] STREAM CONNECTED 6083 @/com/ubuntu/upstart unix 3 [ ] STREAM CONNECTED 6082 root@vlinux:~# root@vlinux:~# root@vlinux:~# root@vlinux:~# telnet localhost 80 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET / HTTP/1.0 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/html;charset=ISO-8859-1 Date: Thu, 19 Feb 1970 03:54:51 GMT Connection: close