Openfire Strophe IE cross-domain problem, openfirestrophe

Source: Internet
Author: User
Tags website domain names

Openfire Strophe IE cross-domain problem, openfirestrophe


Openfire and Strophejs website domain names are different how to communicate, this problem is finally solved, the following is the solution steps.

Solution 1:By default, Chrome supports cross-origin access to IE, which requires Configuration: click "Tools"> "Internet Options"> "security"> "Custom Level" in IE to select "enable" or "prompt" for "access data source through domain" in "other" options ", click OK. Solution 2:Use nginx to perform reverse proxy and configure cross-origin scripts. The deployment steps are as follows: Openfire deploys the machine domain name a http protocol http: //: 7070/http-bind/Tomcat deployed website domain name B website http: // B: 8080/* 1 Openfire server add nginx as the direction proxy 1.1 nginx. add the following configuration in the conf file
 location /http-bind/ {              proxy_redirect off;          proxy_set_header Host $host;            proxy_set_header X-Real-IP $remote_addr;            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;            proxy_pass http://A:7070/http-bind/;           }

Note: The nginx port is 80. Access http: // A/http-bind/After configuration is equivalent to access http: // A: 7070/http-bind/

1.2 Add the crossdomain. xml file to the nginx html folder
<?xml version="1.0"?><!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"><cross-domain-policy>    <site-control permitted-cross-domain-policies="all"/>    <allow-access-from domain="*" to-ports="5222,5223,7070,7443" secure="true"/></cross-domain-policy>

 

2. Add a js file and related plug-ins for cross-origin JS2.1 on the Web interface 2.2html interface reference cross-origin js and strophejs
    <script src='strophe/strophe.js'></script>    <script src='strophe/flXHR.js'></script>    <script src='strophe/strophe.flxhr.js'></script> 

2.3 Specific applications

Interface reference js
<script src='strophe/basic.js'></script>

The usage of basic. js is as follows:

var BOSH_SERVICE = 'http://A/http-bind/';var domain= 'A';var connection = null;$(document).ready(function () {    connection = new Strophe.Connection(BOSH_SERVICE);    connection.rawInput = rawInput;    connection.rawOutput = rawOutput;    $('#connect').bind('click', function () {var button = $('#connect').get(0);if (button.value == 'connect') {    button.value = 'disconnect';    connection.connect($('#jid').get(0).value+"@"+domain,       $('#pass').get(0).value,       onConnect);} else {    button.value = 'connect';    connection.disconnect();}    });});

Download: http://download.csdn.net/detail/caiping07/9388726

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.