如何密码保护使用替代htaccess的nodejs应用 [英] How to password protect nodejs application using alternative to htaccess

查看:196
本文介绍了如何密码保护使用替代htaccess的nodejs应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我主持的AWS与www.domain.com有2子域test.domain.com和stage.domain.com网站。我使用的意思是发展,现在我要的是密码保护我的子域test.domain.com和stage.domain.com,但以类似的方式,因为我们在PHP做使用htaccess的。

I have a site hosted in aws with www.domain.com with 2 sub domains test.domain.com and stage.domain.com. I am using MEAN for development, now what i want is to password protected my sub domains test.domain.com and stage.domain.com but in a similar fashion as we do in php using htaccess.

现在我个人很喜欢这种htaccess的方法,因为这种方法你code的应用将是相同的,认证将被htaccess的增加。 不知道如何做,在nodejs不改变应用程序code,这样我可以删除,在未来,如果我想

Now i personally like this htaccess approach because in this approach your code for the application will be same, authentication will be added by htaccess. Any idea how to do that in nodejs without altering application code, so that i can remove that in future if i want.

P.S。 :仅提示是欢迎

P.S. : Only hints are welcomed.

推荐答案

的.htaccess不会改变code,因为它使用的Apache网络服务器。

.htaccess does not alter the code because it's used by the Apache webserver.

考虑到Node.js的是你的网络服务器,所以这就是魔法发生(在技术上,它需要较少的code添加BASICAUTH到节点,而不是添加到htaccess的APACHE +写.htacess文件)。

Consider that Node.js IS your webserver, so that's where the magic happens (technically, it takes less code to add basicAuth to node than to add htaccess to apache + write the .htacess file).

东西,冥冥中已经知道,认证是必须要做的:)

Something, somewhere has to know that authentication is to be done :).

这里的链接到一个简单的方法来做到这一点的节点:

Here's the link to an easy way to do that in node :

<一个href="http://stackoverflow.com/questions/23616371/basic-http-authentication-with-node-and-ex$p$pss-4">Basic与节点和Ex preSS 4 HTTP认证

这篇关于如何密码保护使用替代htaccess的nodejs应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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