If you use python then you might have used “python -m SimpleHTTPServer 8000” at some point in time to share files with your friends on LAN. Sometimes we want to share large files from one computer to another and we need it. Sometimes it also happens that you are taking a session and you need to share a large file with everyone else. SimpleHTTPServer of python is good but it’s single threaded. It can only handle one client at a time so if you want to share file with a large number of people on LAN it is a bad option. Also SimpleHTTPServer doesn’t work properly if you are sharing large files.
Here’s a very neat alternative to this problem using docker. Go to the directory in which your file is located and from inside that directory type the below command.
docker run -it -p 8082:80 -v $(pwd):/usr/share/nginx/html nginx
Please note that the above command will create a web server with all the files present in the directory from which you started this command. Now just give others your IP address to others and ask them to enter IP_ADDRESS:8082 in their browser. That’s it.
With this simple hack you can easily share large files without any issues on LAN.
Check it out
I am in a directory which has a file which I want to share
~/t/testdir ❯❯❯ ls dropbox_2015.10.28_amd64.deb ~/t/testdir ❯❯❯
Since I want to share this filie with people on LAN, I ran the command which I mentioned.
After running the command I gave my IP address and the port number “8082” to my friend. He can access the website on his browser but you can see the 403 Forbidden error. That’s because directory listing is by default disabled in nginx. To download the file you have to provide them the full name of file. e.g http://localhost:8082/dropbox_2015.10.28_amd64.deb, It will start downloading the file.