LoginSignup
0
1

More than 1 year has passed since last update.

AzureVMで外部からwebサーバーに接続できない場合の対処方法

Posted at

この記事ではAzureVMでWindowsDockerを使用して建てたwebサーバーに外部から接続できない場合の問題の切り分けを行いながら対処する方法を載せています。

環境

Azure
VirtualMachines使用(WindowsServer 2019)
セキュリティグループを使用

Docker内でつながるか

docker ps

コンテナ名を確認します。

docker exec -it <コンテナ名> bash

コンテナに接続します。

curl http://localhost:8080/

エラーが帰ってきたり何もかえって気なかった場合はwebサーバーが起動していない
可能性があります。

VM上でつながるか

VM上の適当なwebブラウザを開いてURLに http://localhost:8080/を入力し接続します。

curl http://localhost:8080/

D
でも大丈夫です

つながらない場合、dockerのポート設定ができてない可能性があります。
dockerコマンドの場合 -p 80:80等の-pオプションが入っているか確認します。

docker run -d -p 8080:80 <コンテナ名>

docker-composeの場合はportsの記入漏れが無いか確認します。

version: '3'

services:
  nginx:
    image: nginx:1.15
    ports:
      - "127.0.0.1:8080:80"

外部PCからつながるか

・セキュリティグループの設定

AzurePortal上からセキュリティグループを開きます。
セキュリティグループ設定で対象のポートが解放されているか確認します。

Untitled.png

・WindowsDefenderの設定

WindowsDefenderで新規の受信の規則の設定を行います。

Untitled.png
受信の規則から新しい規則を選択します。

以上です。

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