Raghuram Vadapalli
Raghuram Vadapalli

Reputation: 1240

Access SimpleHTTPServer from outside Network

Apache server can be set up and accessed from ouside Network in the following way: http://lifehacker.com/124212/geek-to-live--how-to-set-up-a-personal-home-web-server I want to achieve similar functionality with python SimpleHTTPServer. How is this possible?

Upvotes: 11

Views: 39135

Answers (4)

Himanshu Bhatnagar
Himanshu Bhatnagar

Reputation: 1

Yeah, localtunnel helps you in external access of python http.server. Here external access means - to access your http.server from outside the network (suppose you're in Delhi running python http.server and want your friends who are in Bangalore to see the directory contents).

Requirements:

  1. nvm (for installing localtunnel)

  2. use 'lt' (CLI tool) on a specific port (but remember, in order to make external access on your python http.server you need to run python -m http.server along with )

Upvotes: 0

Nilay
Nilay

Reputation: 79

In case the port 8000 is blocked in your firewall, you have to open it.

For example, on RHEL/CentOS/Fedora, open port 8000 as shown below.

#firewall-cmd --permanent --add-port=8000/tcp

#firewall-cmd --reload

On Debian, Ubuntu you can allow the port as shown below.

$ sudo ufw allow 8000

Upvotes: 2

Trishant Pahwa
Trishant Pahwa

Reputation: 2972

You can either port forward your router to the specific port and use a dynamic DNS service such as no-ip to reach your server.

Or you could use a tunneling software like localtunnel.me or ngrok to forward your port to a unique URL.

Or you could create a reverse proxy or a VPN server if you own a cloud server such as AWS or DigitalOcean.

Upvotes: 0

Robᵩ
Robᵩ

Reputation: 168806

Step 1: Run this command "python -m SimpleHTTPServer". Note that python -m SimpleHTTPServer works only with python 2. With python 3, you should use: python -m http.server

Step 2: Edit your router's configuration to forward port 8000 to the computer on which you ran the python command.

Step 3: Determine your home network's IP address, for example, 203.0.113.47

One convenient way to determine your home network's IP address is to consult any of the what-is-my-ip websites, for example https://www.whatismyip.com/.

Step 4: From outside your network, visit (for example) http://203.0.113.47:8000/

Upvotes: 12

Related Questions