This project is a simple HTTP proxy server written in Go that removes CORS (Cross-Origin Resource Sharing) restrictions by setting appropriate headers on the response.
- Removes CORS restrictions for client-side cross-origin requests.
- Caches responses to improve performance.
- Configurable through environment variables.
These instructions will cover usage information for the Docker container.
- Docker
To build the Docker image, run the following command from the root of the repository:
docker build -t corsair .
To run the proxy server in a Docker container, execute:
docker run -d -p 8080:8080 --name my-proxy corsair
This will start the proxy server on port 8080.
The proxy server can be configured using both environment variables and command-line flags. When both are provided, command-line flags take precedence over environment variables.
CORSAIR_PORT
: Port to run the proxy server on. Defaults to8080
if not set.CORSAIR_INTERFACE
: Network interface to listen on. Defaults tolocalhost
if not set.CORSAIR_DOMAINS
: Comma-separated list of allowed domains for forwarding. Defaults to*
(all domains) if not set.CORSAIR_TIMEOUT
: Timeout in seconds for the HTTP client. Defaults to15
if not set.CORSAIR_CACHE_SIZE
: Size of the cache. Defaults to100
if not set.
--port
: Specify the port to run the proxy server on.--interface
: Specify the network interface to listen on.--domains
: Specify the allowed domains for forwarding.--timeout
: Specify the timeout in seconds for the HTTP client.
For example, to start the server on port 8081
with a timeout of 10
seconds you can use the following command with environment variables:
docker run -d -p 8081:8081 --name my-proxy -e CORSAIR_PORT=8081 -e CORSAIR_TIMEOUT=10 corsair
Please feel free to contribute to this project. Pull requests are welcome.
This project is licensed under the MIT License - see the LICENSE file for details.