Use apache to configure tomcat application integration php forum-discuz

Source: Internet
Author: User
Using apache to configure tomcat applications to integrate php forum-discuz recently launched a web application. the main site is a tomcat-based java application, and the php Forum discuz needs to be integrated.

The tomcat application port is 8101, the apahce port is 80, and the website domain name is www.example.com.

Use the xampp server to directly integrate apache and php to install discuz.

To access the tomcat main site through www.example.com, use www.example.com/bbs] to access the discuzforum.

Because tomcat port is 8101 and cannot be accessed directly through www.example.com, you need to use apache VirtualHost to implement

The configuration is as follows:

 
      ProxyPass /bbs !                                                                           ProxyPass / http://example.com:8101/myweb/    ProxyPassReverse / http://example.com:8101/myweb/    ProxyPassReverseCookiePath / /
 

Explanation

ProxyPass / http://example.com:8101/myweb/
Indicates that proxy access will be performed to access the root directory of the website. The access address is the tomcat application address. Note that: The end of the path must end with a slash (/); otherwise, access will fail.

ProxyPassReverse / http://example.com:8101/myweb/
The reverse proxy is consistent with ProxyPass.

ProxyPassReverseCookiePath / /

Cookie path, which must be configured. Otherwise, the website session will be lost and the cookie cannot be saved. the configuration here indicates that the cookie path of the root node is/(you can also set it to another one, for example :)

ProxyPassReverseCookiePath / /myweb

ProxyPass /bbs !
Indicates that the/bbs directory is not accessed by proxy, that is, bbs uses apache for direct access. if this item is not configured,/bbs will use tomcat for access.

Access can be properly configured as expected. But one problem is that the session via http://www.example.com and http://example.com cannot be consistent, that is, after I log on with example.com, I use

When you access www.example.com, the logon session will be lost.

Check the cookie path and find that the cookie domains for session persistence are different. one is www.example.com and the other is example.com. By checking the information, the cookie domain must be set

.Example.com. Note that there must be a point before the domain name. do not add www or http.


However, the configuration item ProxyPassReverseCookieDomain of apache is invalid in this case because the cookie of the main site is set by tomcat and the configuration using apache is invalid. Required

Modify tomcat configuration and conf/context. xml

 

In this way, access through the http://www.example.com and http://example.com can keep the session consistent

This article is my personal experience in data query and practice. if you say something wrong (or have a better solution), please note.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.