Apache Reverse-Proxy如何修复跨域

时间:2016-12-07 21:32:34

标签: apache reverse-proxy

我试过了:

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>

我的Javascript / jQuery代码是:

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

仍存在跨域问题。

1 个答案:

答案 0 :(得分:0)

试试这个

if (Schema::hasTable('messages')){

你是否配置了apache来侦听端口82? e.g。

<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>