User Tools

Site Tools


doc:appunti:linux:sa:proxy_debug

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
doc:appunti:linux:sa:proxy_debug [2011/09/15 15:50] – created niccolodoc:appunti:linux:sa:proxy_debug [2011/09/15 17:44] niccolo
Line 1: Line 1:
-====== Substitute HTML or JavaScript with a proxy ======+====== Substitute HTML or JavaScript on the fly ======
  
-===== How to test changes to live site without touching it =====+Using this recipe - while browsing a remote server - you can trick your browser into taking one file (JavaScript, HTML, image, ecc.) from a web server controlled by you, instead of from the original server. 
 + 
 +This can be useful to test some changes on production server without actually touching the deployed code. 
 + 
 +It works by telling the browser to use a proxy for a particular URL, and configure a fake web server to serve that content, eventually canged.
  
 Create a file **''proxy.pac''** and store it into your web server: Create a file **''proxy.pac''** and store it into your web server:
Line 8: Line 12:
 function FindProxyForURL(url, host) { function FindProxyForURL(url, host) {
     if (shExpMatch(url, "http://remote.server.com:8084/subdir/page.jsp?query_string")) {     if (shExpMatch(url, "http://remote.server.com:8084/subdir/page.jsp?query_string")) {
-        return "PROXY your.server.org:8080";+        return "PROXY your.server.org:8084";
     }     }
 } }
 </code> </code>
  
-Configure the fake VirtualHost on your web server:+Configure fake ''VirtualHost'' on your web server:
  
 <file> <file>
 +NameVirtualHost *:8084
 +Listen 8084
 +
 +<VirtualHost *:8084>
 +    ServerName remote.server.com
 +    DocumentRoot /var/www/remote.server.com
 +    ServerAdmin webmaster@rigacci.org
 +    ErrorLog /var/log/apache2/remote.server.com/error.log
 +    CustomLog /var/log/apache2/remote.server.com/access.log combined
 +
 +    # Force .jsp to be served as HTML
 +    AddType text/html .jsp
 +
 +    <Directory /var/www/remote.server.com>
 +        AllowOverride All
 +    </Directory>
 +</VirtualHost>
 </file> </file>
  
-The put the fake file into the DocumentRoot fo the VirtaulHost **''/var/www/remote.server.com/subdir/page.jsp''**.+Then put the fake file into the DocumentRoot for the VirtaulHost. In the example above it will be **''/var/www/remote.server.com/subdir/page.jsp''**
 + 
 +Configure the browser to use automatic proxy configuration, and give **''%%http://your.server.org/proxy.pac%%''** as the URL.
  
-Configure the browser to use automatic proxy, and give **''%%http://your.server.org/proxy.pac%%''** as the URL.+**NOTE:** This trick does not work with Internet Explorer, because it caches the proxy configuration on a per-server basisIf one page from the server was got via proxy, all the subsequent pages will be too.
doc/appunti/linux/sa/proxy_debug.txt · Last modified: 2011/09/15 17:45 by niccolo