This is probably pretty simple but I just can't wrap my head around it.
I set up a subdomain, let's say it's
nc.example.com. Set up my DNS and all to point the subdomain to a remote server, which runs Nginx which reverse proxies the request to port
Then, I listen for requests using netcat on the remote server, like this:
nc -l 3123
So that I can receive HTTP requests from
Next, on my local machine, I use netcat to connect to an unrelated server (Google's public DNS), like this:
$ nc 184.108.40.206 80 GET / HTTP/1.1 Host: nc.example.com
(with extra 2 newlines so that it completes the HTTP request, but can't be displayed here)
I receive the connection on my remote server as follows:
$ nc -l 3123 GET / HTTP/1.1 Connection: upgrade Host: nc.example.com X-Real-IP: <redacted_1> X-Forwarded-Host: nc.example.com X-Forwarded-Server: nc.example.com X-Forwarded-For: <redacted_2>, <redacted_1>
Now, I'm not sure why this happens, because I thought that
nc will connect to
220.127.116.11, rather than my server's IP address. Is
18.104.22.168 forwarding the request to my server on my behalf? Are there any security implications as a result of this?
I just realised that
<redacted_2> is a private IP address (
172.24.199.96) assigned to my "home" network (accessing it brings me to my router's homepage). I am doing this within my college's network.
Does this mean that the upstream router is proxying the request for me, based on the
Host header? It's understandable because my college recently implemented some sort of network filtering though there's not much details about it. Though I don't understand why it behaves this way?