开发者

How to keep apache as front and tomcat as back end?

Basically i want my tomcat to run o开发者_开发百科n PORT 80 how do i do that because whenever i have to access something then i have to go for localhost:8080/resource but instead i want to use the link as only localhost/resource how do i achieve this?

Currently on my machine apache is running on 800 port and tomcat on 8080.


it seems you are looking for something called Reverse Proxy. Using Reverse Proxy, you will have

  1. apache on 80 port
  2. tomcat on 8080 port

so when access http://xxx.test.com/resource, the request first go though apache, apache then pass the request tomcat, tomcat do the corresponding things and return response to client. have a look at:

  1. http://www.apachetutor.org/admin/reverseproxies
  2. mod_jk: http://tomcat.apache.org/download-connectors.cgi


Tomcat documentation has a HOWTO for this.

http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html

Its a good practice to never expose Tomcat directly internet. You can use Apache for serving static content and send only those requests to tomcat that need dynamic content.


In server.xml find the element that reads

Connector port="8080"

and change it to 80. Save and restart tomcat. Just make sure that apache is running on port 800 otherwise it will now clash with tomcat.


To modify the HTTP port for Tomcat, modify the configuration file server.xml (located in Tomcat's conf directory). Find the HTTP connector element (that is currently configured to port 8080), change the port number to 80, and restart Tomcat.

Note that this is not going to work if any other running service is currently bound on port 80.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜