微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我怎样才能添加基本身份validation到一个nginxconfiguration与重写

我有以下Nginxconfiguration我想添加到这个configuration的基本身份validation。

upstream PHPfcgi { server 127.0.0.1:7777; # server unix:/var/run/PHP5-fpm.sock; #for PHP-FPM running on UNIX socket } server{ listen 80; server_name qu.abc.com; root /home/qu/website/current/web; location / { # try to serve file directly,fallback to rewrite try_files $uri @rewriteapp; } location @rewriteapp { # rewrite all to app.PHP rewrite ^(.*)$ /app.PHP/$1 last; } location ~ ^/(app|app_dev|config).PHP(/|$) { fastcgi_pass PHPfcgi; fastcgi_split_path_info ^(.+.PHP)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS off; } error_log /var/log/Nginx/project_error.log; access_log /var/log/Nginx/project_access.log; }

我已经编辑了位置块

location / { # try to serve file directly,fallback to rewrite auth_basic "Restricted"; auth_basic_user_file /home/qu/website/current/web/.htpassword; try_files $uri @rewriteapp; }

但是这个不能用于重写。 有人可以帮忙吗?

在URL中有两个用户@的请求会导致Google AdSense发出“政策违规通知

是否有可能在Apache2中有两个密码文件

Rails 3,Authlogic,Nginx和HTTP基本authentication不能很好地结合在一起

Apache2 – 授权用户使用BasicAuth而不是本地子网外的用户

Apache 2.2redirect到SSL *然后* auth(解决scheme<但它是废话?)

什么是base64明文的用户名密码

Nginx基本authentication – redirect到401authentication错误的主页

基本身份validation和智威汤逊

如何使用HTML5audio播放器以基本身份validation播放HTTPS安全audiostream

如何使用Glassfish实现基本身份validation?

这听起来像你想要为整个服务器启用基本身份验证,而不是一个单一的location 。 location的工作方式是一次只应用一个位置,因此如果您在单个location指定了一个身份验证策略,但是它会对其他location进行rewrite ,那么另一个location将不会受制于来自身份验证策略的身份验证以前的location

根据auth_basic的文档,它似乎不仅允许在location上下文中使用,而且还可以在server和http 。

因此,如果您希望整个server要求身份验证,只需将所有auth_basic指令从一个location到一个location ,即可将其移到单个server 。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐