Now, first off, let’s get this question out of the way. What is a proxy? A proxy can do different things, however the main idea, is that it acts like a middle man. For example, if I make a request to YouTube for a cat video, that request is sent to the proxy. The proxy then asks the YouTube for the video, and will continue to send the video to me. The main advantage to this approach, is that the server doesn't know that YOU asked, and is led to believe you’re the proxy.
So, how do we make our own? There are many ways to make this server locally, however that would require port forwarding, using sites like no-ip, and is a mess. You could rent a server from sites like Digital Ocean, but then it’s not free anymore. The solution? repl.it. Repl.it is a site that allows you to execute code, online, for free. Recently, they added the ability for free users to have internet access, and even more recently, you can now host sites, on their site! This amazing site, is where we build our proxy.
The language we will be using is python, due to it’s simplicity and awesome library, flask. Flask is a simple back-end framework, that we will use to build our server. Assuming you already have a repl created by now on the website, let’s get started. (FYI, The title says 10 lines. That’s only if you remove all blank lines. I will add them so it’s more readable.)
From here, we simply import Flask, and requests. Repl.it will install these modules when you run it. We’re using requests to fetch for the site we’re proxying. Then, we create an app instance, which we will use to run the server.
Then, we will set a variable equal to the site’s name. Keep in mind, if a bunch of content ends up giving errors when trying to access it, add a
/ to the end of the SITE_NAME url (for example, google.com doesn’t work as well as google.com/). Then, we create a function wrapped in 2 decorators. The first decorator simply states, call this function when they go to the site. The second decorator says to call the function if a path is supplied, then pass the path into the function. Then, we actually create the function.
This is fairly simple. Here, we make a get request to the site, based on the SITE_URL, and the path supplied by the client. If you wanted to be really fancy, you could also make it so it handles GET, PUT, POST, DELETE, PATCH, and other methods. However for our use, this is just fine. We then return the information returned from the site.
Here, we just have an if statement to check that it’s not being imported (which it won’t be), and then run the server. YOU MUST run on port 8080 on repl.it, and have the ip be 0.0.0.0. If you’re doing this somewhere other than repl.it, the port should be 80. Your file should look something like this:
And you’re done! That easy! Run the program, and you’ll have full access to the site, and no one but your program knows it. Change the SITE_NAME variable to whatever you want. If you want to try it out, you can use it here
With that said, I hope you learned something new! Please, don’t just copy the code, try and understand it! If you have any suggestions, feel free to leave a comment below, and don’t use this program to try and bypass sites in your school or workplace. Thanks for reading, and have a great day!
EDIT: After testing on another account, some times repl.it sets __name__ to “builtins” when it should be “__main__”. This is the code, if you have that issue.