HTTPS Redirect in puma only working for the base URL

1.8k views Asked by At

My puma server redirects from http -> https (in development) but only with one URL: localhost:3000. As soon as I add anything to the end (i.e. localhost:3000/index) it no longer redirects (and the page errors out).

Is there a config option I'm missing (or need to comment out)? I currently have:
ssl_bind 'localhost', '3000' { ... } in config/puma.rb and
force_ssl = true in config/environments/development.rb.

1

There are 1 answers

2
Vasfed On

force_ssl is supposed to redirect all requests that come to http port to https, it cannot do anything when you're trying to connect via http to a https port.

http and https should be bound to different ports (bind and ssl_bind options). It is customary to have http development server at port 3000, so bind ssl at some other port (for example - 8443, standard for https is 443, but it's privileged)

Also for development specify ssl_options for redirecting:

config.ssl_options = {  redirect: { status: 307, port: 8443 } }