Now what if you want to access your newly configured server from the outside? If you're connected to internet via an airport network, or through a modem/router, this could be a problem. Indeed, all the requests from the internet will be blocked by the router. Fortunately, there's a way to allow connections through a router.
If you're connected via Airport, just open the «Airport Admin Utiliy» program, located in /Applications/Utilities/, and connect to your base station. Then click «Show All Settings», and go to the «Port Mapping» section. You'll see this:
You just have to open the desired ports. Let's take an example with the HTTP port (used for the internet). The port number is 80. Enter that number in both the «Public Port» and «Private Port» fields. Then enter the IP of your machine (which can be found in the System Preferences, in Network) in the «Private Address» field.
That's it. If you update the base station with those settings, all connections on the 80 port of the base station will be redirected to the 80 port of your computer. So from the outside, if you open the base station IP in a browser, you'll connect to your computer's web server.
The steps are the same if you're connected to the internet through a modem/router. Connect to your router, and add the desired ports, with your IP address. This is, for example, the configuration screen of my own router, actually a Netopia.
You can here define a range of ports, but if you don't want to, just put the same port number in all the fields. Refer to your modem configuration manual, or to your ISP, to know more about the configuration of your specific model.
You'll find here a list of the usual ports on OS X. You don't have to open all of them, but if you need to access a special service of your local server from the outside, just add the corresponding port to your router's configuration. To access the web server, you only need to open the port 80, with the virtual host's ports, if you defined any in the previous chapter.
Port: | Protocol: | Description: |
|---|---|---|
20 | ftp-data | File Transfer Protocol / Data Protocol used to transfer files from one computer to another over a network. |
21 | ftp | File Transfer Protocol / Control Protocol used to transfer files from one computer to another over a network. |
22 | ssh | Secure Shell Protocol used to open a shell session on a remote machine. |
23 | telnet | Telnet Protocol used to open a telnet session on a remote machine. Deactivated by default on Mac OS X, for security reasons. Use SSH instead. |
25 | smtp | Simple Mail Transfer Protocol Protocol used to send mails from a remote mail server. |
80 | http | Hyper Text Transfer Protocol World Wide Web protocol. |
110 | pop3 | Post Offce Protocol Protocol used to transfer mails from a remote mail server. |
115 | sftp | Secure FTP FTP protocol with secure connections and data transfers. |
143 | imap | Interet Message Access Protocol Protocol used to access mails stored on a remote mail server. |
443 | https | HTTP Secure HTTP protocol with secure connections and data transfers. |
548 | afp | AppleTalk Filing Protocol Protocol used by the file sharing capabilities of Mac OS X. Used to access another Mac over a network. |
3306 | mysql | MySQL Protocol used to access a remote MySQL server. |
To get a complete list of all the port numbers, please refer to the Internet Assigned Numbers Authority (IANA) web site (http://www.iana.org/assignments/port-numbers).