从不同域访问 bugzilla Web 服务的好方法是什么?

发布于 2024-10-19 17:39:05 字数 580 浏览 5 评论 0原文

我有两个网站 products.company.combugzilla.internal.com。我想从 products.company.com 页面访问错误信息。我设置了一个 jQuery ajax 函数来对 bugzilla.internal.com/jsonrpc.cgi 进行 jsonrpc 调用。然而,由于跨域脚本限制,这被 apache 阻止了(正如预期的那样)。然后我将ajax发送到products.company.com上的cgi脚本,然后在该脚本中使用curl来发送对bugzilla.internal.com/jsonrpc.cgi的请求,但现在它说

您无权访问 /jsonrpc.cgi

该怎么办?

如果它使任务更简单,我只想使用 获取 bug 功能。

I have two sites products.company.com and bugzilla.internal.com. I would like to access bug information from the products.company.com page. I set up a jQuery ajax function to make a jsonrpc call to bugzilla.internal.com/jsonrpc.cgi. However due to cross domain scripting restrictions, this was blocked by apache (as expected). So then I shot the ajax to a cgi script on products.company.com and then used curl in that script to shoot off the request to bugzilla.internal.com/jsonrpc.cgi, but now it says

You don't have permission to access
/jsonrpc.cgi

What to do?

if it makes the task any simpler, I only want to use the get bug feature.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦亿 2024-10-26 17:39:05

如果 products.company.com 上的 Web 服务器是 Apache,则可以设置 ProxyPass。

如果您无法修改 Web 服务器配置,那么 products.company.com 上的简单代理 cgi 就可以解决问题:

#!/usr/bin/perl

use LWP::UserAgent;
use CGI qw(:standard);



my $URL='http://bugzilla.internal.com/jsonrpc.cgi';

my $q = new CGI;
my $query = &query_string();

my $req = HTTP::Request->new(POST => $URL);
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);

my $ua = LWP::UserAgent->new;
$res = $ua->request($req);

if ($res->is_success) {
   printf "Content-Type: %s\n\n", $res->header('Content-Type');
   print $res->content;
} else {
   printf "Content-Type: text/plain\n\n";
   print "Error: " . $res->status_line . "\n";
}



print $cgi->header(-type => 'text/xml');
print $response->decoded_content;

If your web server at products.company.com is Apache, you can set up a ProxyPass.

If you can't modify web server configuration, then a simple proxy cgi at products.company.com can do the trick:

#!/usr/bin/perl

use LWP::UserAgent;
use CGI qw(:standard);



my $URL='http://bugzilla.internal.com/jsonrpc.cgi';

my $q = new CGI;
my $query = &query_string();

my $req = HTTP::Request->new(POST => $URL);
$req->content_type('application/x-www-form-urlencoded');
$req->content($query);

my $ua = LWP::UserAgent->new;
$res = $ua->request($req);

if ($res->is_success) {
   printf "Content-Type: %s\n\n", $res->header('Content-Type');
   print $res->content;
} else {
   printf "Content-Type: text/plain\n\n";
   print "Error: " . $res->status_line . "\n";
}



print $cgi->header(-type => 'text/xml');
print $response->decoded_content;
浅唱ヾ落雨殇 2024-10-26 17:39:05

你有几个选择。您可以让 products.company.combugzilla.internal.com 发出请求,并让它基本上充当代理。

另一种选择是使用客户端的 jsonp - 这将允许跨域调用。 这是一篇关于 jsonp 入门的非常好的 IBM 文章。

You have a couple options. You can have products.company.com make the request to bugzilla.internal.com and have it basically act as a proxy.

Another option would be to use jsonp from the client - this will allow for cross domain calls. Here's a pretty good IBM article on getting started with jsonp.

灵芸 2024-10-26 17:39:05

有多种解决跨域脚本限制的方法。我还没有测试过,但是 easyXDM 似乎可以做你想做的事情。

There are several work arounds for cross domain scripting restrictions. I haven't tested it, but easyXDM seems to do what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文