意思就是当访问80端口时重定向到8081端口,这样,我们可以改成任何我们需要的端口啦。
[root@tomcat57conf]# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8081 [root@tomcat57conf]# 2.3,切换到tomcat账号,启动tomcat服务就可以正常访问了:
INFO: Deploying web application directory databox [org.springframework.web.context.ContextLoader]Root WebApplicationContext: initialization started [org.springframework.web.context.support.XmlWebApplicationContext]Refreshing Root WebApplicationContext: startup date [Mon Jun 01 18:42:44 CST 2015]; root of context hierarchy [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring.xml] [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring-mybatis.xml] [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer]Loading properties file from class path resource [config.properties] [org.springframework.beans.factory.support.DefaultListableBeanFactory]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@71d7c3ff: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,receiptService,posmonitorService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,dataSource,sqlSessionFactory,org.mybatis.spring.mapper.MapperScannerConfigurer#0,transactionManager,transactionAdvice,org.springframework.aop.config.internalAutoProxyCreator,transactionPointcut,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,receiptMapper,posMonitorLogsMapper]; root of factory hierarchy [com.alibaba.druid.pool.DruidAbstractDataSource]maxIdle is deprecated [com.alibaba.druid.pool.DruidDataSource]{dataSource-1} inited [org.springframework.web.context.ContextLoader]Root WebApplicationContext: initialization completed in 1433 ms [org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization started [org.springframework.web.context.support.XmlWebApplicationContext]Refreshing WebApplicationContext for namespace 'springMvc-servlet': startup date [Mon Jun 01 18:42:45 CST 2015]; parent: Root WebApplicationContext [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]Loading XML bean definitions from class path resource [spring-mvc.xml] [org.springframework.beans.factory.support.DefaultListableBeanFactory]Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5d4ee178: defining beans [receiptController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mappingJacksonHttpMessageConverter,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,multipartResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@71d7c3ff [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData] onto handler 'receiptController' [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData.*] onto handler 'receiptController' [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receiveReceiptData/] onto handler 'receiptController' [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData] onto handler 'receiptController' [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData.*] onto handler 'receiptController' [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping]Mapped URL path [/receiptController/receivePosInfoData/] onto handler 'receiptController' [org.springframework.web.servlet.DispatcherServlet]FrameworkServlet 'springMvc': initialization completed in 377 ms Jun 01, 2015 6:42:45 PM org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8081 Jun 01, 2015 6:42:45 PM org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:9109 Jun 01, 2015 6:42:45 PM org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/16 config=null Jun 01, 2015 6:42:45 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 6827 ms ^C