Question

I have

my website locally on my Mac ready to host. It is accessible locally via http://localhost running on MAMP. Let’s say my static public IP from my ISP is : 201.23.45.23 and I’ve already linked that IP with a domain like this : 201.23.45.23 —> http://mysite.online


Goal

I want to make my site accessible on the web, and host it on my local Mac. I want my clients to see what I see on my http://localhost when they visit

http://201.23.45.23

or

http://mysite.online


Note

I know that I can purchase a VPS or shared host, but the my intention here is to learn how to do it on my own on my local machine.


Question

Do I need to update my router to open port 80 and configure a port forward for that port? Do I need to download an extra FTP server app like FileZilla to configure this ?

How would one go about and configure something like this ?

Any hints/suggestions/directions on this will be much appreciated !

Was it helpful?

Solution

Usually you don't need any additional tools like FTP-clients because you already have direct access to your file system via the Finder or the shell.


Since your host resides in a private network and connects to the internet via a gateway (your router) remote users don't have direct access to your Mac - they don't even know that it exists.

To enable access for remote users, you have to forward the public port 80 (and possibly port 443) on the router to the respective host's ports. Usually the router interface already contains preconfigured port-forwarding rules or you have to add them yourself:

public-router-ip:public-port –> host-ip:private-port

Here is an example of a D-Link router interface. Here I assume your host has the IP 192.168.0.2 and your web-server has the ports 80/443 open, the router's IP is 201.23.45.23:

enter image description here

All requests to 201.23.45.23:80 and 201.23.45.23:443 are forwarded to your internal host and its respective ports then: 192.168.0.2:80 and 192.168.0.2:443.

Name is here: a human readable name tagging the service. This may be the protocol name (e.g. HTTP) or a service name (e.g. Web server (http)). The drop down menu Application Name will probably auto-populate it - I don't own a D-Link Router so I don't know this.
In IP Address enter the IP address of your local Mac hosting the web server - not your public IP. The drop down menu Computer Name will probably show all available hosts in your internal network.
Public/Private Port as well as Traffic Type are self-explanatory.

The designations may differ slightly in your router's interface!

The standard MAMP http/https ports are 8888 and 8890 though. If you haven't changed this, the proper port-forwarding rules on the router would look like this then:

enter image description here

This means: all requests to 201.23.45.23:80 will be forwarded to 192.168.0.2:8888 and 201.23.45.23:443 to 192.168.0.2:8890 respectively.

You may even tell your clients to access the web server at port 20080/20443 (e.g. mysite.online:20080/main.htm). This is not recommended and inconvenient for your clients - it's just an example to show how to do it.

The forwarding rules with the standard MAMP http/https ports are then:

enter image description here


If you want to operate your own web server like this, I advise to set up a virtual machine (connected to a bridged interface - not NATed!) with VirtualBox, VMware Fusion or Parallels, install OS X & MAMP and run it there.

This will prevent ravaging your real system.

Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange
scroll top