简体   繁体   English

JavaScript没有通过代理传递

[英]JavaScript is not being passed through proxy

I don't seem to understand something about proxying and JavaScript. 我似乎不了解代理和JavaScript。 I have searched several posts, but I am none the wiser... 我搜索了几个帖子,但我不是更聪明的...

I have a CentOS (6.4) server that functions as a proxy for another server (ARMv7). 我有一个CentOS(6.4)服务器,作为另一个服务器(ARMv7)的代理。 Both run Apache; 两者都运行Apache; the first one is version 2.2.15, the second one is version 2.2.22. 第一个是版本2.2.15,第二个是版本2.2.22。

The proxy config on the first server is as follows: 第一台服务器上的代理配置如下:

ProxyPass /PV/    http://192.168.0.30/electricity/

When calling http://mysite.bla.xxx/PV/ , I do get (part of) the index.html file served that is on the second server. 当调用http://mysite.bla.xxx/PV/时 ,我确实得到了第二台服务器上提供的index.html文件(的一部分)。 However, the index.html file starts with this: 但是,index.html文件以此开头:

<html>
  <head>
  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  <script type="text/javascript" src="/javascript/jquery/jquery.js"></script>
  <script type="text/javascript">
  ......

And here's where it goes wrong... When I examine the error-log on the proxyserver, I see: 这就是它出错的地方......当我检查代理服务器上的错误日志时,我看到:

File does not exist: /var/www/html/javascript, referer: http://mysite.bla.xxx/PV/ 文件不存在:/ var / www / html / javascript,referer: http//mysite.bla.xxx/PV/

And of course, this file/directory does not exist. 当然,这个文件/目录不存在。

I'm guessing that the second <script> tag is the culprit, because it wants to find something at /javascript locally on the first server that doesn't exist. 我猜第二个<script>标签是罪魁祸首,因为它想在第一台不存在的服务器上本地找到/ javascript的东西。

Am I right? 我对吗? If so, how can I get Apache on the proxying server to serve the scripts included in index.html on the second server? 如果是这样,我如何让代理服务器上的Apache为第二台服务器上的index.html中包含的脚本提供服务?

Drop the first slash from the js's URL. 从js的URL中删除第一个斜杠。

Not <script src="/javascript/jquery/jquery.js"> 不是<script src="/javascript/jquery/jquery.js">

but <script src="javascript/jquery/jquery.js"> 但是<script src="javascript/jquery/jquery.js">

Paths beginning with a slash will be assumed to reside in root. 以斜杠开头的路径将被假定为驻留在root中。 Thus your link points to http://mysite.bla.xxx/javascript/jquery/jquery.js 因此,您的链接指向http://mysite.bla.xxx/javascript/jquery/jquery.js

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

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