密码保护Rails网站运行在Nginx和Phusion乘客 [英] Password protecting Rails site running on Nginx and Phusion Passenger

查看:164
本文介绍了密码保护Rails网站运行在Nginx和Phusion乘客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用基本的http身份验证来保护我刚刚部署的Rails 3应用。它正在最新的Nginx / Passenger上运行,我使用以下Nginx指令来保护Web根目录:

I want to protect my newly deployed Rails 3 app with the basic http authentication. It's running on the latest Nginx/Passenger and I'm using the following Nginx directive to protect the web root directory:

location = / {
  auth_basic "Restricted";
  auth_basic_user_file htpasswd;
}  

htpasswd文件是使用Apache htpasswd utililty生成的。但是,输入正确的用户名和密码后,我将被转移到403 Forbidden错误页面。分析Nginx错误日志显示:

htpasswd file was generated using Apache htpasswd utililty. However, after entering correct username and password I'm getting transferred to the 403 Forbidden error page. Analyzing Nginx error log revealed this:

directory index of "/var/www/mysite/public/" is forbidden, client: 108.14.212.10, server: mysite.com, request: "GET / HTTP/1.1", host: "mysite.com"

显然,我不想列出mysite / public目录的内容。如何正确配置它,以便Rails应用程序在我输入登录信息后启动?

Obviously, I don't want to list the contents of the mysite/public directory. How can I configure this properly so the Rails app starts after I enter my login info?

推荐答案

您需要重新指定passenger_enabled在位置块中。

You need to re-specify passenger_enabled in the location block.

这篇关于密码保护Rails网站运行在Nginx和Phusion乘客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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