我们使用 nginx 作为反向代理并启用了http_auth_request_module。我们希望将请求缓存到我们的身份验证服务器以减少该服务器的负载。这是到目前为止的 nginx 配置:
server {
...
location /sso {
auth_request /identity;
proxy_pass http://localhost:8081;
}
location /identity {
internal;
proxy_pass http://localhost:8081;
proxy_cache_path /opt/nginx/cache levels=1:2 keys=authentication:1m;
proxy_cache authentication;
proxy_cache_key $cookie_authentication;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
}
Run Code Online (Sandbox Code Playgroud)
正在接受请求并且身份验证有效。但是没有任何内容写入缓存目录。Nginx 有足够的权限写入缓存目录:
drwxrwxrwx 2 nobody wheel 68B Jul 18 16:34 cache
Run Code Online (Sandbox Code Playgroud)
如何使 http_auth_request_module 从缓存中读取并使 nginx 将响应写入缓存?
是否可以在位置块中发送http子请求并使用proxy_pass指令中的响应?
用例
我的上游应用程序需要API中的一些其他信息.我编写了一个使用proxy_pass指令代理请求的位置块.在nginx将请求发送到我的应用程序之前.我想向我的API发送一个HTTP请求,并使用几个响应头作为我的应用程序的请求标头.
这是我想要实现的概要:
server {
server_name ...;
location {
# perform subrequest to fetch additional information from an api
proxy_pass myapplication;
proxy_set_header X-Additional-Info "some information from the subrequest";
}
}
Run Code Online (Sandbox Code Playgroud)
该行为类似于auth_request模块.但是,我找不到使用标准nginx配置在位置块内发送额外阻塞HTTP请求的文档.
我正在尝试手动安装自制程序。自制程序可以工作,但我在符号链接方面遇到问题。
我做了什么:
/usr/localmkdir homebrew && curl -L
https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip
1 -C homebrewusr/local/homebrew/bin/brew install wget问题是自制程序安装的内容没有符号链接。brew在终端中也找不到该命令。自制软件生活在/usr/local/homebrew