承上一篇使用 mod_rails 當做開發環境,要在 local 開發測試 SSL 網頁,使用 mod_rails 是最方便的選擇,以下是我在自己 Mac Leopard 上的安裝步驟:

1. 首先是產生 SSL Keys

# Generate certificate
openssl req -new > server.csr
openssl rsa -in privkey.pem -out server.key
openssl x509 -in server.csr -out server.cert \
-req -signkey server.key -days 365

然後把產生出來的 server.key 跟 server.cert 放到 /etc/apache2/ 下,server.cert 改名成 server.crt,然後都 chmod 成 400 唯讀。

2. 編輯 /etc/apache2/httpd.conf,打開 Include /private/etc/apache2/extra/httpd-ssl.conf

3. 編輯 /etc/apache2/extra/httpd-ssl.conf,確認 SSLCertificateFile 跟 SSLCertificateKeyFile 指向步驟一中的兩個檔案。

4. 編輯你的 vhost 設定,加入以下:

NameVirtualHost *:443

5. 之前設定好的 <VirtualHost *:80> 區段整個複製一份,並改成 443。然後在其中加入以下:

RequestHeader set X_FORWARDED_PROTO 'https'

至此就裝好了,重開 apache 即可,還蠻簡單的。


Rss Commenti

1 Commento

  1. [...] 在這裡只考慮「用 Apache 的 OpenSSL 自己簽發 SSL 憑證」的方式,如果你透過管道 ($) 取得 SSL Key 和憑證,那應該可以跳過這步。參考的是 ihower 前輩的這篇文章,不過我把操作寫得詳細一點。 [...]

    #1 [攻略] Ruby on Rails 與 SSL (https) « YORKXIN×YORKXIN

Lascia un Commento