3

反向代理一个网站,可以设置指定目录密码,但是直连无需密码?

 1 year ago
source link: https://www.v2ex.com/t/911504
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  问与答

反向代理一个网站,可以设置指定目录密码,但是直连无需密码?

  jsjcjsjc · 1 小时 38 分钟前 · 239 次点击
7 条回复    2023-01-30 10:48:34 +08:00
kaedeair

kaedeair      1 小时 5 分钟前   ❤️ 1

可以搞一个摘要认证的中间件,通过匹配路径来重定向,认证完毕再转回去,之前用 traefik 搭建 htpc 的时候实现过
cosmain

cosmain      57 分钟前   ❤️ 1

nginx 的 location 配置+http basic authentication
jsjcjsjc

jsjcjsjc      51 分钟前 via iPhone

@cosmain 这个方案我以前试过,直连也要密码哈
cosmain

cosmain      48 分钟前

@jsjcjsjc
那说明你路径匹配没有写好。
killva4624

killva4624      40 分钟前

location ~ ^/folder/\S+
{
...
# Process with files
}

location ~ ^/folder {
....
# Process with auth
# auth_basic "Administrator Login";
# auth_basic_user_file /other_folder/.htpasswd;
}
jsjcjsjc

jsjcjsjc      18 分钟前 via iPhone

@kaedeair 是的,现成的方案吗?感谢
kaedeair

kaedeair      9 分钟前

@jsjcjsjc 6# nginx 因为没怎么用过,所以不太熟悉,思路是差不多的
2 楼的方案应该是能行的

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK