Skip to content

Instantly share code, notes, and snippets.

@tommeier
Created July 12, 2012 04:27
Show Gist options
  • Save tommeier/3095717 to your computer and use it in GitHub Desktop.
Save tommeier/3095717 to your computer and use it in GitHub Desktop.
Install local ssl with pow
# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=*.#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
system "openssl rsa -in #{domain_name}.key.bak -out #{domain_name}.key"
system "openssl x509 -req -days 365 -in #{domain_name}.csr -signkey #{domain_name}.key -out #{domain_name}.crt"
end

Add port forward file (add 5000 to .port file)

cd /path/to/newco_app
vi .port
bundle exec foreman start

Install POW

curl get.pow.cx | sh
cd ~/.pow
ln -s /path/to/newco_app/.port jqdev

##Update Brew & install Nginx

brew update
brew install nginx

You should have v1.2.2 installed, any other version (lower) can have strange issues

Alter Nginx install

Apply nginx.conf and gen_cert.rb as listed below

cd /usr/local/etc/nginx
vi nginx.conf
mkdir ssl
cd ssl
vi gen_cert.rb
ruby gen_cert.rb jqdev.dev
sudo nginx
open https://hooroo.jqdev.dev

Mark certificate as secure locally (Chrome)

  • When viewing https://hooroo.jqdev.dev
  • Click the crossed padlock icon top left
  • Click 'certificate information'
  • Drag the large certificate icon to your desktop
  • Double click and add to keychain
  • Right click and choose 'get info' on the '*.jqdev.dev'
  • Change 'When using this certificate' to 'Always trust'
  • Refresh in Chrome
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
### server port and name ###
listen 443 ssl;
server_name *.jqdev.net;
### SSL log files ###
access_log logs/ssl-access.log;
error_log logs/ssl-error.log;
### SSL cert files ###
ssl_certificate ssl/jqdev.dev.crt;
ssl_certificate_key ssl/jqdev.dev.key;
### Add SSL specific settings here ###
keepalive_timeout 60;
### We want full access to SSL via backend ###
location / {
proxy_pass http://jqdev.dev;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
### Set headers ####
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
### Most PHP, Python, Rails, Java App can use this header ###
proxy_set_header X-Forwarded-Proto https;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment