nginx反向代理弹簧安全认证GET而不是POST

时间:2018-11-06 18:40:50

标签: tomcat nginx centos7

我无法正确设置Nginx作为tomcat托管应用程序的反向代理,该应用程序使用spring安全性进行身份验证。 应用程序上的spring身份验证模块正在拒绝

的登录

2018-11-06 19:30:01 DEBUG http-nio-8443-exec-398 @ 1951e0f24163 [OneTimePasswordAuthenticationFilter] - Authentication request failed: org.springframework.security.authentication.AuthenticationServiceException: Authentication method not supported: GET

Nginx日志似乎正在作为GET请求发送身份验证,我不明白为什么,但是我可以看到失败的原因:

192.168.0.1 - - [06/Nov/2018:18:08:56 +0000] "POST /rear/j_spring_security_check HTTP/1.1" 302 161 "https://nginx_server/remote_rear/login/auth?login_error=1" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" "-"
192.168.0.1 - - [06/Nov/2018:18:08:56 +0000] "GET /remote_rear/j_spring_security_check HTTP/1.1" 302 0 "https://nginx_server/remote_rear/login/auth?login_error=1" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" "-"
192.168.0.1 - - [06/Nov/2018:18:08:56 +0000] "GET /rear/login/authfail;jsessionid=81EF0C82C98FC746D7641E6845E105D7?login_error=1 HTTP/1.1" 302 161 "https://nginx_server/remote_rear/login/auth?login_error=1" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" "-"

根据我能够在Google上进行测试的内容,我当前的代理配置是:

server {
   listen 443 default_server ssl;
        location /remote_rear {
            proxy_set_header  Host  $http_host;
            proxy_set_header X_FORWARDED_PROTO '$https';
            proxy_set_header  X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass      https://real_server:8443/rear;
            #proxy_redirect     https://real_server:8443/rear /rear;
            proxy_redirect     http://$host https://$host;
        }
        location /rear {
            proxy_set_header Host $http_host;
            proxy_set_header X_FORWARDED_PROTO '$https';
            proxy_set_header  X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            rewrite ^/rear/(.*)$ /remote_rear/$1 redirect;
        }
}

我真的很困惑为什么j_spring_security_check URL是作为GET而不是POST发送的,我真的很感谢有人解释我做错了什么以及如何解决。 提前非常感谢!

0 个答案:

没有答案