This is a Proxy Server for Node.js submitted as the pre-work requirement for CodePath.
Time spent: [5 hrs]
Completed:
8000
are echoed back with the same HTTP headers and body--host
, --port
or --url
argumentsx-destination-url
header--logfile
argument outputs all logs to the file specified instead of stdoutWalkthrough Gif:
Video Walkthrough Starting the Server
babel-node index.js (npm start/ bode not working on windows machine)
Features
Echo Server: (Also working for Localhost)
curl -v -X POST http://127.0.0.1:8000 -d "hello self" -H "x-asdf: yodawg"
POST / HTTP/1.1 User-Agent: curl/7.37.1 Host: 127.0.0.1:8000 Accept: / x-asdf: yodawg Content-Length: 10 Content-Type: application/x-www-form-urlencoded
Port 8001 will proxy to the echo server on port 8000.
curl -v http://127.0.0.1:8001/asdf -d "hello proxy"
POST /asdf HTTP/1.1 User-Agent: curl/7.37.1 Host: 127.0.0.1:8001 Accept: / Content-Length: 11 Content-Type: application/x-www-form-urlencoded
CLI Arguments:
The following CLI arguments are supported:
--8000
The host of the destination server. Defaults to 127.0.0.1.
--8000 --8001
The port of the destination server. Defaults to 8000 when a host is not specified.
curl -v http://127.0.0.1:8000 -d "hello world" -H 'x-asdf: foo'
The follow http header(s) are supported:
x-destination-url