{"id":15672576,"url":"https://github.com/rossta/local-ssl-demo-rails","last_synced_at":"2025-05-06T21:25:48.859Z","repository":{"id":66515663,"uuid":"147364312","full_name":"rossta/local-ssl-demo-rails","owner":"rossta","description":"Rails 5 demo app with local SSL for development and test environments","archived":false,"fork":false,"pushed_at":"2018-09-05T21:32:25.000Z","size":206,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-06T10:17:38.856Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rossta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-04T15:03:41.000Z","updated_at":"2023-08-25T09:10:57.000Z","dependencies_parsed_at":"2023-02-20T23:45:17.306Z","dependency_job_id":null,"html_url":"https://github.com/rossta/local-ssl-demo-rails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossta%2Flocal-ssl-demo-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossta%2Flocal-ssl-demo-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossta%2Flocal-ssl-demo-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossta%2Flocal-ssl-demo-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rossta","download_url":"https://codeload.github.com/rossta/local-ssl-demo-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252770816,"owners_count":21801593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T15:28:28.581Z","updated_at":"2025-05-06T21:25:48.838Z","avatar_url":"https://github.com/rossta.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/rossta/local-ssl-demo-rails.svg?style=svg)](https://circleci.com/gh/rossta/local-ssl-demo-rails)\n# Local SSL Demo for Rails\n\nThis Rails 5 application is a simple demo for getting SSL running for local development and test environments. \n\n[Blog post](https://rossta.net/blog/local-ssl-for-rails-5.html)\n\n![Local SSL Demo](./local-ssl-demo.png)\n\n## Requirements\n\nBelow is a list of binaries and gems with the versions used in this demo. It may be possible to make this work with other relatively recent versions of these tools, though your mileage may vary.\n\n### Binaries\n\n```\n$ openssl version\nLibreSSL 2.2.7\n\n$ ruby -v\nruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]\n\n$ /Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version\nGoogle Chrome 68.0.3440.106\n\n$ /Applications/Firefox.app/Contents/MacOS/firefox --version\nMozilla Firefox 60.0.1\n\n$ ~/.webdrivers/chromedriver -v\nChromeDriver 2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db)\n\n$ ~/.webdrivers/geckodriver --version\ngeckodriver 0.21.0\n```\n### Gemfile\n\n```ruby\ngem 'rails', '~\u003e 5.2.1'\ngem 'puma', '~\u003e 3.12'\ngem 'webpacker', '~\u003e 3.5.5' # optional\n\ngroup :test do\n  gem 'capybara', '~\u003e 3.5.1'\n  gem 'selenium-webdriver', '~\u003e 3.14.0'\n  gem 'webdrivers', '~\u003e 3.3.3'\n  gem 'rspec-rails', '~\u003e 3.8.0' # optional\nend\n```\n\n## Register a local top level domain\n\nFor custom \"pretty\" wildcard domains, you can use a domain name registered to loop back to the local IP `127.0.0.1` like `lvh.me` or you can run `dnsmasq` locally to achieve the same effect for which ever domain you want.\n\nInstall and start dnsmasq\n```\nbrew install dnsmasq\nmkdir -pv $(brew --prefix)/etc\nsudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons\nbrew services start dnsmasq\nsudo mkdir -pv /etc/resolver\n```\nAdd a resolver for a TLD you'd like to resolve locally. In this example, we'll use the username returned from `whoami`.\n```\nlocal_tld=$(whoami)\necho \"address=/.$local_tld/127.0.0.1\" | sudo tee -a $(brew --prefix)/etc/dnsmasq.conf\necho \"nameserver 127.0.0.1\" | sudo tee /etc/resolver/$local_tld\n```\n\n## Generate a wildcard SSL certificate\n\nTo generate a self-signed SSL certificate that will work for both arbitrary subdomains and the domain appex, we need make use of the Subject Alternative Name X.509 extension via a configuration file.\n\n```bash\nname=localhost.$(whoami)\nopenssl req \\\n  -new \\\n  -newkey rsa:2048 \\\n  -sha256 \\\n  -days 3650 \\\n  -nodes \\\n  -x509 \\\n  -keyout $name.key \\\n  -out $name.crt \\\n  -config \u003c(cat \u003c\u003c-EOF\n  [req]\n  distinguished_name = req_distinguished_name\n  x509_extensions = v3_req\n  prompt = no\n  [req_distinguished_name]\n  CN = $name\n  [v3_req]\n  keyUsage = keyEncipherment, dataEncipherment\n  extendedKeyUsage = serverAuth\n  subjectAltName = @alt_names\n  [alt_names]\n  DNS.1 = $name\n  DNS.2 = *.$name\nEOF\n)\n```\nMove the generated files to a location of your choosing, such as the `config` directory of your Rails project:\n```\n$ mv localhost.ross.crt localhost.ross.key config/ssl\n```\nFinally, we can instruct Keychain to trust are newly generated certificate. Some browsers like Chrome will rely on the System settings\n```\n$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain config/ssl/localhost.ross.crt\n```\n### Server configuration\n\nIf you're running Nginx locally to reverse proxy requests for `https://localhost.ross` to your local Rails server, you can configure it to handle SSL requests using your key/crt file pair.\n\nWithout Nginx, you can boot the Rails Puma server so that it will bind to our local domain name over SSL:\n\n```\nbin/rails s -b 'ssl://127.0.0.1:3000?key=config/ssl/localhost.ross.key\u0026cert=config/ssl/localhost.ross.crt'\n```\nA similar command can be found in the Procfile for use with `foreman` locally.\n\n## Acknowledgements\n\nThe guide for setting up SSL for local development is based off of Jed Schmidt's excellent\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossta%2Flocal-ssl-demo-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frossta%2Flocal-ssl-demo-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossta%2Flocal-ssl-demo-rails/lists"}