全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1219|回复: 13

帮忙解决个alist的nginx配置问题搞定给50块钱

[复制链接]
发表于 2023-2-13 14:55:15 来自手机 | 显示全部楼层 |阅读模式
nginx反代配置里面加入了如下basic auth:
auth_basic "请 输 入 用 户 和 密 码 "; # 验 证 时 的 提 示 信 息
auth_basic_user_file /etc/nginx/password; # 认 证 文 件

然后我也在nginx配置中加了如下header头:
proxy_set_header   Authorization "";
可是输完密码后尽管正确还是反复让我输密码,我百分百确认不是密码不正确的原因,因为我把location /里面的block换成下面的马上就认证成功了:
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
这个貌似是http basic auth和alist默认鉴权有冲突导致的,详情见下面这个issue:
https://github.com/fatedier/frp/issues/1545
MJJ大神帮忙搞定后我双手奉上50红包哈~
 楼主| 发表于 2023-2-13 15:05:07 来自手机 | 显示全部楼层
没有MJJ帮忙看一下么~
发表于 2023-2-13 15:20:18 | 显示全部楼层
nginx的server字段能发一下吗? @ChatWithMe_a_bot
 楼主| 发表于 2023-2-13 15:35:09 来自手机 | 显示全部楼层
mjj666zzz 发表于 2023-2-13 15:20
nginx的server字段能发一下吗? @ChatWithMe_a_bot

server {
listen 80 default_server;
listen [::]:80 default_server;
auth_basic "请 输 入 用 户 和 密 码 "; # 验 证 时 的 提 示 信 息
auth_basic_user_file /etc/nginx/password; # 认 证 文 件
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
#location / {
# # First attempt to serve request as file, then
# # as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
#}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Range $http_range;
proxy_set_header If-Range $http_if_range;
proxy_redirect off;
proxy_pass http://127.0.0.1:5244;
# the max size of file to upload
client_max_body_size 20000m;
}
}
完整的server如上哈~
发表于 2023-2-13 16:25:29 | 显示全部楼层
本帖最后由 jarmoku 于 2023-2-13 16:27 编辑

proxy_set_header Authorization "Basic a2luZzppc25ha2Vk";
来自
https://serverfault.com/questions/230749/how-to-use-nginx-to-proxy-to-a-host-requiring-authentication

理论上Authorization "Basic a2luZzppc25ha2Vk";后面不能是空的啊
发表于 2023-2-13 16:32:34 | 显示全部楼层
https://t.me/ruyybxx
 楼主| 发表于 2023-2-13 16:33:14 来自手机 | 显示全部楼层
jarmoku 发表于 2023-2-13 16:25
proxy_set_header Authorization "Basic a2luZzppc25ha2Vk";
来自
https://serverfault.com/questions/2307 ...

额。。我之前的jenkins就是这么干的一切正常,那我这个basic后面的密码要填alist的管理员密码呢还是文件夹密码呀,那啥我还开了两步验证了,另外这样子用近乎明文的密码写在nginx里面不会有啥事吧MJJ~
发表于 2023-2-13 16:33:31 | 显示全部楼层
jarmoku 发表于 2023-2-13 16:25
proxy_set_header Authorization "Basic a2luZzppc25ha2Vk";
来自
https://serverfault.com/questions/2307 ...


这样试试

  1. server {
  2. listen 80 default_server;
  3. listen [::]:80 default_server;
  4. server_name _;

  5. location / {
  6. auth_basic "请 输 入 用 户 和 密 码 ";
  7. auth_basic_user_file /etc/nginx/password;
  8. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9. proxy_set_header X-Forwarded-Proto $scheme;
  10. proxy_set_header Host $http_host;
  11. proxy_set_header X-Real-IP $remote_addr;
  12. proxy_set_header Range $http_range;
  13. proxy_set_header If-Range $http_if_range;
  14. proxy_redirect off;
  15. proxy_pass http://127.0.0.1:5244;
  16. # the max size of file to upload
  17. client_max_body_size 20000m;
  18. }
  19. }
复制代码
 楼主| 发表于 2023-2-13 16:35:21 来自手机 | 显示全部楼层
diocat 发表于 2023-2-13 16:32
https://t.me/ruyybxx

这是啥呀老哥
发表于 2023-2-13 16:35:42 | 显示全部楼层

TG联系方式
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-16 03:15 , Processed in 0.063266 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表