Source: https://jtpck.com/blog/running-rails-with-ssl-in-development

# Running Rails with SSL in the Development Environment

Learn how to configure HTTPS in your Rails development environment for testing secure features, service workers, and third-party integrations.

By JTPCK Team · Aug 18, 2025

When working on Rails applications, it can be useful to run your development server over HTTPS. This allows you to test features like secure cookies, service workers, and third-party integrations that require SSL. In the `config/environments/development.rb` file, Rails is configured to accept requests from a custom domain by appending it to the `config.hosts` list:

<!-- -->

```ruby
Rails.application.configure do
  config.hosts << ".example.com"
end
```

Next, the `config/puma.rb` file is updated to enable SSL:

```ruby
ssl_bind "0.0.0.0", "8443", {
  key: "server.key",
  cert: "server.crt"
}
```

By binding Puma to port 8443 and providing certificate and key files, the Rails server will respond over HTTPS locally. You can generate the certificates with tools such as Certbot. Once you have your certificate files, place them in your Rails application root directory or update the paths in the Puma configuration accordingly. Once the server is running, you may want to expose it remotely for testing. An SSH reverse tunnel can forward the local SSL port to a remote server:

```bash
ssh -R 8443:localhost:8443 -N user@example.com
```

With this setup you can work securely with HTTPS in your development environment, test against real-world conditions, and share your development server over a secure tunnel when needed. This configuration is especially valuable when developing applications that integrate with services requiring SSL or when testing browser features that only work over HTTPS.
