1. Install nginx

2. Configure nginx

3. Configure nginx as a launchd daemon

4. Put SSL certificates in place

5. Add the SSL configuration in nginx.conf

1. Install nginx

port install nginx +ssl +zip +gzip_static

See other variants with port info nginx

2. Configure nginx

cd /opt/local/etc/nginx

cp nginx.conf.default nginx.conf

cp mime.types.default mime.types

Make sure that nginx runs executing nginx in the terminal.

3. Configure nginx as a launchd daemon

Create the file /System/Library/LaunchDaemons/nginx.plist with the following

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"

                       "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

  <dict>

    <key>Label</key><string>nginx</string>

    <key>Program</key><string>/opt/local/sbin/nginx</string>

    <key>KeepAlive</key><true/>

    <key>NetworkState</key><true/>

    <key>StandardErrorPath</key><string>/var/log/system.log</string>

    <key>LaunchOnlyOnce</key><true/>

  </dict>

</plist>

Then run

launchctl load -F /System/Library/LaunchDaemons/nginx.plist

4. Put SSL certificates in place

If you have an SSL certificate, you don’t have to create one.

Otherwise, assume that your host is example.com and use this script to create a self  signed certificate.

 ssl example.com

Then put the certificate and its key in place

cd /opt/local/etc/nginx

mkdir ssl

mv example.com.key ssl/

mv example.com.crt ssl/

chmod 400 ssl/example.com.key

5. Add the SSL configuration in nginx.conf

Modify nginx.conf to match your certificate and key. The relevant lines in my case after modifying the configuration file look like this:

server {

        listen       80;

        listen       443 ssl;

        server_name  dev-mini.example.com;

        ssl_certificate         ssl/example.com.crt;

        ssl_certificate_key     ssl/example.key;