Nginx and Tomcat cross-domain issues

Source: Internet
Author: User

Project Purpose: STB Portal

Environment Description:

1, using Nginx 1.8.1 load static page *.html, on the static page to invoke the service interface ;

2, Tomcat 6 load project;

Problem: The Set-top box cannot access the page and cannot load the data.

Analysis:

1, check the interface log, incoming and outgoing information are normal;

2, grab the packet, analysis data show no problem.

Ajax is not receiving the returned data information, looked for a long time this problem, the original is cross-domain to intercept.

Process

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/89/3A/wKioL1gNo5qwmyP6AABRBQysXUo828.png-wh_500x0-wm_3 -wmp_4-s_3217498546.png "title=" flowchart "alt=" Wkiol1gno5qwmyp6aabrbqysxuo828.png-wh_50 "/>

Solution 1:

Modify the Tomcat configuration file Tomcat/conf/web.xml, modify the filter configuration, add:

<filter>

<filter-name>CorsFilter</filter-name>

<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>CorsFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

Note: The tomcat version needs to be above tomcat7.0.4;


Solution 2:

Modify Nginx configuration file, this does not do the verification, here does not do the detailed description.


Special thanks to teacher Yang, money teacher.



Nginx and Tomcat cross-domain issues

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.