0

How do you set up SSL on the localhost ITSELF (not on any virtual hosts) using MAMP PRO?

I need to do this so I can preview the website I'm creating on my iPhone, which uses the same Wi-Fi ip address.

(To do this, I just type in the IP address of the WiFi in the address bar of my iPhone browser).

Thanks very much in advance!!

2 Answers2

0

You can check those articles : Getting MAMP working with SSL on Mac OS X.

  • I have already been there. The info is either outdated or is not relevant to making SSL work on Localhost itself (again, I emphasize, not virtual host) –  Jan 26 '13 at 00:25
0

It sounds like you're confused regarding what localhost is. Localhost is always local: this is the machine itself and has 127.x.x.x as an IP address (usually 127.0.0.1). If you run MAMP on your Mac, connection to localhost from your iPhone or any other device will be of no use. As far as your iPhone is concerned, localhost is the iPhone itself.

If you want to run a test server within your LAN, which probably uses private addresses (typically, 192.168.0.x), you'll need to configure your server for the IP address the machine on which it's running is using (you can normally see this in the network preferences).

As far as Apache Httpd is concerned, this will have to be configured in a VirtualHost (matching that LAN IP address). It's not quite clear what you're after: this is just how Apache Httpd is meant to be configured anyway.

The problem you're going to encounter is that your certificate will need to be valid for that IP address. It's in fact often simpler to allocate a host name (some routers provide small DNS services for the machine for which they also run a DHCP service, for example), and it generally makes more sense. Nevertheless, you can generate a certificate valid for an IP address by using an IP address Subject Alternative Name (SAN) entry (as discussed in this answer, see OpenSSL section). This also implies that you'll need to use your own self-signed certificate or your own mini Certification Authority, and that you'll have to import it somehow into your iPhone for the server certificate to be trusted.

Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376
  • Thanks for the detailed answer Bruno. Indeed I would like to have SSL for the 192.168.0.x IP address. Could you please explain how I can do that with MAMP PRO? By the way, the link in your reply [this answer] does not appear? Thanks again! –  Jan 26 '13 at 14:51
  • Sorry, I've just added the link. I'm not sure about MAMP Pro, but all of this should be the same as for a "normal" Apache Httpd. Use the SSL directives in a `` section (and use `Listen 443`). – Bruno Jan 26 '13 at 15:42