1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Spring Boot で Connection refused にする方法

Posted at

技術的にしたい事

spring boot において、「localhost」以外の接続は Connection refused にしてしまう方法をメモしておく。

目的

spring boot を使用した Web アプリで
スタンドアローンでのみ使用するユースケースの場合、
外部から REST 通信されるような事は出来ないようにしたいはず。

そんな Web アプリって存在するのか・・・?
そもそも REST WebApi 仕様は不明なのでは・・・?
などの突っ込みは気にせず、自マシンだけが使えるようにしたい場合の対処となる。

実装

クラスパス直下に application.properties というファイルを置き、
設定値として以下を追加する。

spring boot 側で自動で読み取ってくれ、
localhost以外は Connection refused にしてくれる。

application.properties
server.address=localhost
server.port=8080

備考

spring boot の設定ファイルについては、下記を参照して下さい。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?