如何密码保护使用替代htaccess的nodejs应用

编程入门 行业动态 更新时间:2024-10-15 10:18:12
本文介绍了如何密码保护使用替代htaccess的nodejs应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have a site hosted in aws with www.domain with 2 sub domains test.domain and stage.domain. I am using MEAN for development, now what i want is to password protected my sub domains test.domain and stage.domain 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 :

Basic与节点和Ex preSS 4 HTTP认证

更多推荐

如何密码保护使用替代htaccess的nodejs应用

本文发布于:2023-11-01 13:28:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549448.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码保护   htaccess   nodejs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!