Ошибка конечной точки Oauth2 oauth / token в Spring Boot за Nginx - PullRequest
0 голосов
/ 11 февраля 2020

Я развертываю приложение Spring Boot за прокси-сервером Nginx. Всякий раз, когда я пытаюсь аутентифицировать пользователя, используя эту конечную точку /oauth/token, я не получаю никакого ответа.

Это мой application.properties

spring.profiles.active=prod
server.port=8088
server.tomcat.remote-ip-header= X-Forwarded-For
server.tomcat.protocol-header= X-Forwarded-Proto

#server.servlet.context-path=/
API.URL=/api/v1

И это метод настройки в WebSecurityConfigurerAdapater

@Override
    protected void configure(HttpSecurity http) throws Exception {
        logger.debug("configure");
        System.out.println("configure ");

        http.requiresChannel().anyRequest().requiresSecure();
        http
                .authorizeRequests()
                .antMatchers("/").permitAll()
                .and()
                .authorizeRequests()
                .anyRequest()
                .authenticated()
                ;

    }

И это мой nginx файл конфигурации

server {
    listen 80;
    server_name myserver.com;

    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name myserver.com;

    ssl_certificate /etc/letsencrypt/live/myserver.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/myserver.com/privkey.pem;
    ssl_trusted_certificate  /etc/letsencrypt/live/myserver.com/fullchain.pem;

    location / {
             proxy_pass        http://myserver:8088;
             proxy_set_header  X-Real-IP $remote_addr;
             proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header  Host $http_host;
             proxy_set_header  X-Forwarded-Proto  $scheme;  
        }
}

Я могу поразить другие конечные точки, но не по oauth/token. Я использую экземпляр Amazon EC2.

Когда я пытаюсь попасть в конечную точку в Почтальоне, я получаю

Error: connect ETIMEDOUT some_ip_that_is_not_ec2_ip:443
Warning: This request did not get sent completely and might not have all the required system headers

И когда я пытаюсь попасть в конечную точку, используя Okhttp, я получаю

Server: nginx/1.17.8
    Content-Type: text/html
    Content-Length: 157
    Connection: close
    <html>
    <head><title>400 Bad Request</title></head>
    <body>
    <center><h1>400 Bad Request</h1></center>
    <hr><center>nginx/1.17.8</center>
    </body>
    </html>

Любая помощь будет принята с благодарностью. Спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...