简体   繁体   English

Apache反向代理如何修复跨域

[英]How Apache Reverse-Proxy to fix cross-domain

I tried this: 我尝试了这个:

Apache Config File: Apache配置文件:

<VirtualHost *:80>
    DocumentRoot "/www"
    ServerName 12.34.56.78
    ProxyPreserveHost On
    ProxyPass "/" "http://12.34.56.78:82"
    ProxyPassReverse "/" "http://12.34.56.78:82"
</VirtualHost>
<VirtualHost *:82>
    DocumentRoot "/www"
    ServerName 12.34.56.78:82
</VirtualHost>

And my Javascript/jQuery code is: 我的Javascript / jQuery代码是:

$.ajax({
        type:'post',
        url:'http://12.34.56.78:80/',
        data:{},
        async:false,
        success:function(data){
           alert('success')
        },
        error : function() {  
           alert('error');
        }  
    });

Cross-domain problem still there. 跨域问题仍然存在。

try this 尝试这个

<VirtualHost *:80>
    ServerName 12.34.56.78
    ProxyRequests off
    ProxyPass "/" "http://12.34.56.78:82"
    ProxyPassReverse "/" "http://12.34.56.78:82"
</VirtualHost>
<VirtualHost *:82>
    DocumentRoot "/www"
    ServerName 12.34.56.78:82
</VirtualHost>

And did you configured apache to listen on port 82? 并且您是否配置了Apache以监听端口82? eg 例如

Listen 82

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM