如何设置本地 SSL 证书和 Rails 应用程序? [英] How can I setup a local SSL certificate and a Rails application?

查看:58
本文介绍了如何设置本地 SSL 证书和 Rails 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个二合一问题.

This might be a two-in-one question.

  1. 我有一个用于家庭/业余爱好的 Rails 应用程序,托管在 Raspberry Pi 上,我想知道是否可以为其创建本地 SSL 证书并设置 Rails 以使用它?

  1. I have a Rails application for home/hobby usage, hosted on a Raspberry Pi and I was wondering if it's possible to create a local SSL certificate for it and setup Rails to use it?

如果是,我该如何设置 Rails/Puma/Foreman/Ubuntu 应用程序?现在,我使用 Procfile 与 Foreman 一起运行应用程序:

If yes, how can I setup my Rails/Puma/Foreman/Ubuntu application? For now, I am running the application with Foreman, by using a Procfile:

web: bundle exec puma -t 8:8 -p 3000
worker: bundle exec sidekiq
clock: bundle exec clockwork config/clock.rb

推荐答案

  1. 是的,你可以.以下是解释该过程的要点:

https://gist.github.com/tadast/9932075

  1. 我的 procfile 包含一个如下所示的条目:

  1. My procfile contains an entry that looks like this:

服务器:rails server puma -b 'ssl://0.0.0.0:3000?key=server.key&cert=server.crt'

server: rails server puma -b 'ssl://0.0.0.0:3000?key=server.key&cert=server.crt'

这似乎对我有用.我也设置了

This seems to work for me. I also set

config.force_ssl = true 

在 config/application.rb 中

in config/application.rb

我从所有这些地方收集了有关它的信息:

I gathered info about it from all these places:

https://github.com/puma/puma

http://www.railway.at/2013/02/12/using-ssl-in-your-local-rails-environment/

http://www.panozzaj.com/blog/2013/08/12/how-to-set-up-local-https-development/

http://www.eq8.eu/blogs/14-config-force_ssl-is-different-than-controller-force_ssl

这篇关于如何设置本地 SSL 证书和 Rails 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆