Giter VIP home page Giter VIP logo

proxy's Introduction

Proxy CI

This application is a proxy that can be used to read content from the web without running into CORS issues. You can use it by calling sending POST requests to the /fetch endpoint.

For example, if the application is being served at https://proxy.example.com you can do:

const request = { url: 'https://duckduckgo.com' };
const response = await fetch('https://proxy.example.com/fetch', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(request),
});
const html = await response.text();

console.log(`Website HTML: ${html}`);

Eventually, I may implement a proper HTTP proxy, but for now this is enough for my use-case.

If you want to use it yourself, feel free to fork it and host it in your own server. I have written some basic instructions to get started, but the app is implemented using Laravel so you can use any workflow that you prefer for development. You can also deploy it using Forge or Vapor.

All these instructions assume that you have installed Docker and you're familiar with the basic concepts.

Development

For development, you can clone the repository and serve it using Laravel Sail. Make sure to also compile assets with npm and add the domain to /etc/hosts.

git clone [email protected]:NoelDeMartin/proxy.git proxy
cd proxy
cp .env.example .env
docker run --rm -v "$(pwd):/app" -w /app laravelsail/php81-composer:latest composer install
./vendor/bin/sail up -d
./vendor/bin/sail artisan key:generate
sudo -- sh -c -e "echo '127.0.0.1 proxy.test' >> /etc/hosts"
npm install
npm run dev

After running these commands, you should be able to use the app on http://proxy.test.

Production

For production, you can use some the Docker Compose configuration that is included in the repository. It is, however, not straight-forward to use because it has some configuration parameters such as the domain where it will be served from and the allowed origins. It is also integrated with nginx-agora, which I use in my server.

In order to simplify this setup, you can use the ./proxy binary:

git clone [email protected]:NoelDeMartin/proxy.git proxy
cd proxy
./proxy install
./proxy start

Run ./proxy to see more commands.

Production (headless)

The code is published in Docker Hub, so if you just want to run the application in the server without modifying any files you can do it in "headless mode". This only means that you won't have the source code checked out in the server, instead you'll only keep the configuration files and folders necessary to run the app using Docker Compose.

This can also be configured using the ./proxy binary:

git clone --branch headless --single-branch [email protected]:NoelDeMartin/proxy.git proxy
cd proxy
./proxy install
./proxy start

Run ./proxy to see more commands.

proxy's People

Contributors

noeldemartin avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.