Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 4.02 KB

README.md

File metadata and controls

44 lines (32 loc) · 4.02 KB

Proxies a request to a given URL by making the request on the server and returning the response. Headers and body will be preserved, therefore the behavior should be identical to making the request directly.

Useful to bypass CORS

License: MIT

Usage

Given your server is running on https://proxy.example.com.

Instead of making a request to a URL directly, prepend the proxy server URL. For example, instead of making a request to https://cors-protected-site.com/anything run the request with https://proxy.example.com/https://cors-protected-site.com/anything.

Endpoint summery

Endpoint Description
/<url> The default proxy endpoint. The http-method, headers, and body will be preserved
/cache/<url> Works just like /<url> but tries to return a cached version of the request and creates a cached version if none is present
/cache/max-age:<max-age>/<url> Like /cache/<url>, but only returns a cached response, if the response if not older that max-age (seconds). Creates a new cached version otherwise

HTTP-Method, headers and body (if available) will be preserved as if making the request directly. Therefore, header-based authentication or sending some form data will still work.

Setup using docker compose

  • Clone this repository
  • Start the server with docker compose up -d --build
  • The server will start on port 9996 by default. This can be chagedin the docker-compose.yml file.

Configure the caching behavior

You can configure the caching behavior of the server by setting some environment variables in the docker-compose.yml file. There are four caching modes available by setting the CACHE_MODE environment variable:

CACHE_MODE Description Additional settings
sqlite Saves the responses in a SQLite database Set the SQLITE_FILE environment variable to modify the cache file. Defaults to data/cache.db.
mysql Connects to a MySQL-database to cache responses Requires setting MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD and MYSQL_DATABASE environment variables accordingly. MYSQL_PORT can be used if the MySQL server is running on a non-standard port.
memory Uses an in-memory cache to store responses (none)
none (default) Disables caching completely. (none)

If an unrecognized value is set for CACHE_MODE, no caching will be used. See the examples for some example docker compose configurations.