Yaxy is a proxy server that replaces various parts of HTTP requests and responses with the values specified in the config file. I will not describe here how to install, configure and start the server, all this is described in the readme repository. Here I will describe the various cases in which Yaxy is very helpful, if not indispensable.
Replacing the hosts file
')
In the simplest case, we will have rules
site.my => 127.0.0.1
As a result, we get the functionality of the hosts file with additional buns:
- The hosts file is cached, sometimes you have to press Ctrl + F5 several times to see the changes. Rules from the Yaxy config are applied immediately after saving.
- Locality The hosts file affects the entire system, but only the browsers you need go through the proxy. Although in some cases this may be a disadvantage.
- Do you have virtual machines with different browsers in them? Each virtual machine has to maintain the hosts file. And you can simply register one proxy server for all browsers.
- Do you check your sites in iPhone / iPad? Well, if there is a developer server, and if not - you have to be stuck in production. With Yaxy, we specify a proxy server on our local computer in the settings and look at all local sites from the phone.
By the way, if the site is on a non-standard port, it is not necessary to write this port in the address bar of the browser, you can specify it in the config.
site.my => localhost:9898
Server guys for so long do everything
And I desperately need support for the
Origin
HTTP header on the site to debug my scripts. No need to wait for anyone.
www.yandex.ru => $ $SetResponseHeader Access-Control-Allow-Origin: *
Now on my computer scripts of any site can read
www.yandex.ru .
We are tested on the necessary data
On your site you follow the Ajax data. Suddenly it turns out that your script crashes on certain data, but it is not so easy to reproduce just such data by the system’s regular means. Yes, to be honest, and it is not yet clear what kind of JSON should be in order for everything to break. You can try to patch the server so that it gives a constant JSON to a specific URL, or you can write in the proxy server config
my-service.my/my-data.json => data:application/json;{"success":false,"error":" "}
Debugging in production
An error was found in the JS code, which is reproduced only in production.
my-service.ru/scripts/main.js => my-service.dev/scripts/main.js
Now the whole site is loaded from production, and the only main.js script is from the local site.
Debugging on another site
You write an attendance counter, or social networking buttons, or an advertising system, or something else that works on other people's sites. You will definitely meet a site where your code will not work. At the same time, the site has a dozen of its scripts and a dozen different informers, and with what your script conflicts - it is not clear.
Well, we save the source code of some page of the site, and in the Yaxy config we write
bad-site.ru/page.html => file:
Nothing has changed for the browser, and now you can fix the page code at your discretion. And then it’s standard - we delete various lines in the file and look, after deleting which the error disappears. Found that the error appears when the file script.js is connected? We substitute it in the same way and see what is wrong with it. After that, at will - or write to the owner that his code in such and such a place, to put it mildly, is so-so, or (which is preferable) adapt your script to similar situations.
Site in 30 seconds
You need to quickly make a two-page saytik to test your hypothesis, and reluctant to mess with Apache.
new-site.my => file:
Now in the c: / www / my-site folder there are site files opening in the browser at the address new-site.my.
We test ayaksovy data loading
Common problem: everything works quickly on localhost, it seems that the load indication is not needed. But even if there is an understanding that some kind of rotating picture is needed, we still do not have time to see it.
my-site.ru/data/data.json => $ $Delay 5
Now the data.json file will load for at least 5 seconds.
We remove interfering HTTP headers
For tests, you need to open a site in the iframe, but the site sends the header
X-Frame-Options: DENY
. Add a rule
site.ru => $ $RemoveResponseHeader X-Frame-Options
No more annoying header.
Order for completion of site scripts
A strange person turned to you: he wants you to write a JS-script for the site, but does not want to give access to the site. And the site is rather complicated, the script must be tested on it. No problem at all. We select some connected JS file (for example, /js/main.js) on the necessary page of the site, save it to us (for example, in /home/me/main.js), add to the Yaxy rule
site.ru/js/main.js => file:
Now the whole site will work as usual, and the main.js file will be loaded locally. We add the new code to the end of the file, then it will be possible to render it separately.
And what if you need to change the layout? No problem too. Save the source of the main page, add the rule
!site.ru/ => file:
Now the entire main page of the site is on your disk, you can change the layout at will.
This is not a complete list of situations in which
Yaxy rescues
me . I would be glad if you find it useful. And of course bug reports are welcome.