使用 Nginx 进行身份验证的方法

ways of authentication with Nginx

我是 Nginx 的新手,所以如果我的问题很明显,请耐心等待。

  1. 我正在寻找向 Nginx 服务器验证用户身份的方法。根据我的研究,我了解到有两个主要选项:

  2. End-user 向 Nginx 发送一个包含私钥的请求(例如在 header 中),Ngnix 将身份验证发送到 auth 服务器,Ngnix 得到一个答案用户是否通过身份验证。

第二个选项是,Nginx plus(一项收费的服务),由 Nginx 处理身份验证过程 - 如果有人知道此选项的 open-source 版本,那将是最好的。

非常感谢大家的帮助,谢谢大家!

  1. 老好Basic authentication still exists, among with the ngx_http_auth_basic_module. Unfortunately the only algorithm that is implemented by nginx itself is the old and weak apache MD5, however using glibc based host systems you have some other options. You can find out more details here.

  2. 您可以使用 client-side 证书对您的用户进行身份验证。互联网上有很多文章;这是 google.

    的第一个搜索结果页面中的 Client-Side Certificate Authentication with Nginx
  3. 可以用js_content directive from njs module as the auth location content handler (instead of proxying auth request to some backend app). Or you can do both things, you may find the Validating OAuth 2.0 Access Tokens with NGINX and NGINX Plus文章很有意思

  4. 您可以使用著名的 lua-nginx-module 实现几乎所有您能想象到的身份验证机制。一些有用的链接(同样,来自 google 搜索结果的第一页)是

  5. 虽然这篇文章只与 Nginx Plus 有关,但为了使答案完整,我不得不提到 ngx_http_auth_jwt_module 和 F5 的一些官方文章: