Proxy server for a web developers.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2ad6cf5 Mar 3, 2016


Описание на русском языке

Yaxy is a proxy-server for a web developer, it substitutes the required resources with simple rules.


If you haven't installed NodeJS already, [then do it] (, then

     npm install -g yaxy


     yaxy --config my-yaxy-config.txt --port 9999 --proxy user:password@proxyhost:3000

If you do not specify --config, Yaxy will look for yaxy-config.txt file in the current directory. The server will listen on port 8558, if no --port specified. If you specify --proxy, Yaxy will route external requests through proxy server.

Configuration File Format

The configuration file is read line by line. Blank lines, lines beginning with # and unknown strings are ignored.

Rules can be combined in sections. Start of the section is a line enclosed in square brackets, the contents of a line can be any.

# Rules out of sections

[Section 1]
# Rules for section #1

[Section 2]
# Rules for section #2

If a section name starts with #, then all rules of this section will be ignored.

# Rules out of sections

[#Section 1]
# Section #1 rules
# will be ignored

[Section 2]
# Rules for section #2


Rules are written like:

url => replacement

url -- domain address string for rule to work. http:// at the beginning of line is not obligaroty. E.g., rule => ... will work for all resources at domain, while => ... -- only for Yandex search.

Sometimes exact address match is required, i.e. you need to modify only site's main page, leaving the rest of it intact. For this specify ! at the beginning of url, http:// is still optional, but trailing slash(es) are a must for exact matching. E.g., replaceing Yandex main page: ! => ....

If first two cases are not enough, you may use regexp for left side, enclosed with /. So, if you'll need to modify all requests to .ru domain, use: /^http://[^/]+\.ru// => .... Please note, regexp uses whole url, including http://.

Simple url substitute

The right side of a rule specifies the replacement for captured match of a rule's left side. E.g., rule => will substitute all request from to, so request goes to, and request to goes to More specific rule => will substitute request to, while leaving intact Please note, if you need to keep path in a domain, you must specify it on both parts of a rule, because => will replace request to

When you have a regexp in a left side of a rule, right side is treated as a template for captured groups. E.g., we replace all *.ru domain requests to *.com: /^(http://[^/]+\.)ru(/.*)$/ => $1com$2.

Displaying local files

You can have your little static-server, using file:// protocol in the right part of a rule.

# windows => file://c:/www/
# linux => file:///home/www/

Directory index file -- index.html. For above example, url will return file /home/www/, and url returns /home/www/

Using data:uri

If your substitute is simple and you don't want to create a file, you may use data:uri. => data:text/html;<script type="text/javascript">alert('Hello!');</script>

Then all urls, starting with will return response with <script type="text/javascript">alert('Hello!');</script>. => data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD///+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4Ug9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC

Get an image for all urls, starting with

If you have a regexp in rule's left side, you may use it's captured groups in the right side.

/^\?name=(.*)/ => data:text/html;<script>alert('Hello, $1!');</script>

Routing requests through proxy

Beside the specifying --proxy on the start, Yaxy can route specific requests through other proxy. => proxy:localhost:3000

With this rule requests to Yandex will be routed through localhost proxy, that listens port number 3000. If Yaxy was started with --proxy localhost:3333 arg, all requests will be routed through localhost default proxy (port 3333), but requests to Yandex will still use route through proxy on port number 3000.

Leaving url intact

If url must be left intact, use $ in rule's right side. => $

Sometimes you don't need to modify a request, but only use some modifiers for it (see below).

Cancelling a request

If right side of rule is left empty, then request will be cancelled (even no http headers will be returned).


Modifiers are strings, starting with $ (leading spaces don't matter). First goes modifier name, after space -- arguments. Modifier corresponds to the rule it is written after. If modifier is written at the file's beginning (before any rule), it applies to all rules. If modifier is written at the section's beginning, then it applies to all section rules.

Please note, global modifiers applies to rules (i.e. requests, matching these rules), and not all requests through proxy server.

Modifying GET-parameters

# Add or modify parameter
$SetQueryParam from=yaxy

# Removing parameter
$RemoveQueryParam from

Cookie manipulations

Cookies are modified for server, so while browser sends an original cookie, server receives the modified one.

# Adding/modifying specific cookie
$SetCookie user=YaxyUser

# Removing a cookie
$RemoveCookie ssid

Modifying HTTP headers

# Setting a request header
$SetRequestHeader X-Requested-With: Yaxy

# Setting a response header
$SetResponseHeader X-Proxy: Yaxy

# Removing request header
$RemoveRequestHeader Referer

# Removing response header
$RemoveResponseHeader Content-Type

Setting root directory for file:// protocol

If all of your projects are located in one directory, you can set root directory one time, instead of doing it each time for every project.

$SetDocumentRoot /home/me/projects

Now you can use this path with tilde (~) => file://~/
# With the previous rule it is equal to
site => file:///home/me/projects/

Also you can set root directory for specific section of rules

$SetDocumentRoot /home/me/projects

$SetDocumentRoot ~/ => file://~/css-dev => file://~/js-dev => file://~    

Modifying response status

# Always HTTP 200 for response (even when it's not)
$StatusCode 200

Response delay

#Respond at least 5 seconds later
$Delay 5