Compare commits
2 Commits
dd686ca0c6
...
eb1dc859ac
Author | SHA1 | Date |
---|---|---|
Roxy | eb1dc859ac | |
Roxy | cf576111d0 |
|
@ -2,14 +2,18 @@
|
|||
|
||||
This project sets up a simple HTTP proxy using Ruby and Nginx. It's designed to forward requests to a specified host, with the option to replace certain strings in the response.
|
||||
|
||||
# IT IS IN NO WAY FINISHED OR IN A STABLE STATE DO NOT FOLLOW THIS GUIDE, IT SERVERS AS A GUIDELINE ON HOW THE INSTALLATION AND FUNCTION SHOULD BE AND NOT YET AS A GUIDE
|
||||
|
||||
## Installation
|
||||
|
||||
To install the necessary dependencies and set up the proxy, run the following command:
|
||||
|
||||
```bash
|
||||
bash installer.sh
|
||||
sudo bash installer.sh
|
||||
```
|
||||
|
||||
Please dont forget to copy the installer from /root/ruby-proxy to your home directory and to change its owner recursively
|
||||
|
||||
This will:
|
||||
|
||||
Install Ruby and the 'webrick' gem.
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"replacements": {
|
||||
"example.com": "example.mydomain.com",
|
||||
"Example": "Example @ Mydomain",
|
||||
"example": "example @ ,ydomain",
|
||||
"https:": "http:"
|
||||
},
|
||||
"host": "example.com",
|
||||
"port": 8000
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
replacements:
|
||||
example.com: example.mydomain.com
|
||||
">example<": "example @ mydomain<"
|
||||
https:: http:
|
||||
host: example.com
|
||||
port: 8000
|
||||
|
|
@ -47,7 +47,7 @@ read -p "Enter proxy_set_header (the host header for the website you wanna modif
|
|||
# Create the Nginx config file
|
||||
if [ ! -f /etc/nginx/sites-available/ruby-proxy ]; then
|
||||
echo "Creating Nginx configuration file..."
|
||||
cat << EOF > /etc/nginx/sites-available/ruby-proxy
|
||||
sudo cat << EOF > /etc/nginx/sites-available/ruby-proxy
|
||||
resolver 8.8.8.8;
|
||||
|
||||
server {
|
||||
|
|
10
proxy.rb
10
proxy.rb
|
@ -3,15 +3,15 @@
|
|||
require "webrick"
|
||||
require "net/http"
|
||||
require "uri"
|
||||
require "yaml"
|
||||
require "json"
|
||||
|
||||
# Load configuration from file
|
||||
config = YAML.load_file(File.join(__dir__, 'config.yml'))
|
||||
CONFIG = JSON.parse(File.read(File.join(__dir__, 'config.json')))
|
||||
|
||||
$replacements = config['replacements']
|
||||
$replacements = CONFIG['replacements']
|
||||
|
||||
class MyProxy < WEBrick::HTTPServlet::AbstractServlet
|
||||
HOST = config['host'] # set host to proxy duh
|
||||
HOST = CONFIG['host'] # set host to proxy duh
|
||||
|
||||
def do_GET(request, response)
|
||||
uri = request.unparsed_uri
|
||||
|
@ -43,7 +43,7 @@ end
|
|||
$stdout.reopen(File.join(__dir__, 'ruby-proxy.log'), 'a')
|
||||
$stderr.reopen($stdout)
|
||||
|
||||
server = WEBrick::HTTPServer.new(:Port => config['port'] || 8000) # define port on which the proxy runs ... so this would be localhost:8000
|
||||
server = WEBrick::HTTPServer.new(:Port => CONFIG['port'] || 8000) # define port on which the proxy runs ... so this would be localhost:8000
|
||||
server.mount "/", MyProxy
|
||||
|
||||
trap("INT"){ server.shutdown }
|
||||
|
|
Loading…
Reference in New Issue