LoginSignup
0
0

More than 1 year has passed since last update.

[SpringBoot] The request was rejected because the URL contained a potentially malicious String "//"

Posted at

問題

SpringBoogのアプリケーションをデプロイしたところ、タイトルのエラーが発生。
この動作自体は、Spring Security が不正なURLでのリクエストを拒否するもので正しい。
ただ、アプリケーション側では、このような不正なURL(連続スラッシュ)は見当たらない。

原因

nginx のリバースプロキシの設定に問題があった。

  location /xxx {
    proxy_pass http://zzz.com:8080/xxx/; ※最後にスラッシュが入っている
    proxy_redirect default;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

このスラッシュがあるがために、アプリケーション内の別ページに移動しようとした際に、(ttp//zzz.com:8080/xxx//yyy) のように "//" が含まれるURLでアクセスされてしまっていた。

対処

  location /xxx {
    proxy_pass http://zzz.com:8080/xxx; ※最後のスラッシュを削除
    proxy_redirect default;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0