我是否仍然需要 NGINX 来提供 JS 等静态内容以及向后端反向代理请求,或者仅使用 Spring Cloud Gateway 即可完成?Spring 文档有以下图像:
我在那里没有找到有关如何将静态内容返回给客户端的描述,这是否意味着它被认为是不好的做法,并且我需要反向代理的额外步骤来增加其延迟?如果没有,我在哪里可以找到有关如何使用 Spring Cloud Gateway 执行此操作的更多信息,特别是如果我要使用 Spring Gateway 进行 oauth2 授权代码流身份验证?
我有一个 NGINX 反向代理,也使用以下配置在 / 上提供静态内容
location / {
auth_request /authn;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 301 302 303 307 308 = @handle_redirect;
gzip_static on;
index index.html;
root /usr/share/nginx/html;
try_files $uri $uri/ @index;
}
location /authn {
set $target http://gateway:8030/authn;
proxy_pass http://gateway:8030/authn;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_pass_request_headers on;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 301 302 303 307 308 @handle_redirect;
}
location @handle_redirect {
proxy_set_header Host $host:$server_port;
set $redirect_url $upstream_http_location;
proxy_pass $redirect_url;
}
Run Code Online (Sandbox Code Playgroud)
目标是通过对 /authn 端点的子请求进行身份验证来检查用户,如果用户不是,它将返回 302 和 …