Report this

What is the reason for this report?

How do I create a browser based proxy/http forwarder?

Posted on April 15, 2015

I’ve looked around and seen some tutorials for reverse proxies and forward proxies but I don’t think they quite fit the scenario. Basically I want to be able to go to

drop.let.ip.address:port/proxy

and from there be able to forward requests to certain websites, either in a pre-configured manner (e.g. /proxy/reddit hardcoded to reddit.com) or via a form submission to get pages on demand. Stretch goals for whitelisted IP addresses and https to be used.

A pointer in the right direction would be greatly appreciated



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You need a “(web-based|php) proxy script”. There are plenty of them on SourceForge, but be careful, they might contain security bugs, malware, or backdoors.

A more decent choice would be to use Glype, which is actively developed and has a support forum.

Creating a browser-based proxy or HTTP forwarder as you’ve described involves setting up a server that receives incoming HTTP requests, processes them, and forwards them to the desired destination. You can use technologies like Node.js with Express or Python with Flask for this purpose. Here’s a high-level guide on how to create such a proxy:

  1. Choose a Programming Language and Web Framework: Decide on the programming language and web framework you want to use for building the proxy server. Node.js with Express, Python with Flask, or similar frameworks are commonly used for this task. Choose one with which you are comfortable.

  2. Set Up Your Development Environment: Install the necessary development tools and libraries for your chosen programming language. For example, if you’re using Node.js, you’ll need Node.js and npm. If you’re using Python, you’ll need Python and pip.

  3. Create a New Project: Start a new project or directory for your proxy server. Initialize your project using the respective package manager (e.g., npm init for Node.js or pipenv for Python).

  4. Install Required Dependencies: Install any dependencies you’ll need for your chosen framework. For Node.js and Express, you might need to install Express itself. For Python and Flask, you’ll need Flask.

  5. Design Your Proxy Server: Define the routes and logic for your proxy server. You’ll need to:

    • Create an endpoint to receive incoming requests (e.g., /proxy).
    • Extract the target URL from the request (either from a pre-configured mapping or a form submission).
    • Make an HTTP request to the target URL using a library like Axios (Node.js) or the requests module (Python).
    • Forward the response back to the client.
  6. Implement URL Mapping: You can hardcode mappings from friendly URLs (e.g., /proxy/reddit) to actual URLs (e.g., https://www.reddit.com) in your code. When a request is made to /proxy/reddit, your server should know to forward it to https://www.reddit.com.

  7. Implement Form Submission (Optional): If you want to allow users to input URLs dynamically, create a form on your /proxy endpoint that accepts the target URL. Process the form submission and use the provided URL to make the request.

  8. Implement Whitelisting (Optional): If you want to restrict access to your proxy to specific IP addresses, you can implement IP whitelisting in your server logic. Only allow requests from whitelisted IPs to access the proxy.

  9. Implement HTTPS (Optional): If you want to use HTTPS, you’ll need to set up SSL/TLS certificates for your server. You can use tools like Let’s Encrypt to obtain free SSL certificates.

  10. Test Your Proxy: Test your proxy server by accessing it in your browser and confirming that it correctly forwards requests to the desired websites.

  11. Deploy Your Proxy: Once you’ve tested your proxy and are satisfied with its functionality, you can deploy it to a production server or cloud hosting platform of your choice.

  12. Secure Your Proxy (Important): Be cautious about security, as running an open proxy can pose risks. Implement security measures, validate user input, and monitor your server for potential abuse.

Remember that creating a proxy server involves handling network requests, so it’s essential to consider security, privacy, and performance aspects.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.