豚吐露@wiki
IISExpressで外部からの接続を許可したい
最終更新:
Bot(ページ名リンク)
-
view
IISExpressで外部からの接続を許可したい
Windows 7 Professional
IIS Express 8.5(Visual Studio 2013 Professional)
IIS Express 8.5(Visual Studio 2013 Professional)
まず、以下のfileを開く。
C:\Users\【ユーザ名】\Documents\IISExpress\config\applicationhost.config
開いたら<site>タグを検索。
これがIISで言う『インターネット インフォメーション サービス (IIS) マネージャー』の設定。
これがIISで言う『インターネット インフォメーション サービス (IIS) マネージャー』の設定。
- <site name="【サイト名】" id="【ID】">
- <application path="/" applicationPool="【アプリケーションプール名】">
- <virtualDirectory path="【エイリアス名】" physicalPath="【dir path】" />
- </application>
- <bindings>
- <binding protocol="http" bindingInformation="*:80:localhost" />
- </bindings>
- </site>
site → name | サイト名は任意のものに変えると、VS上で反映される。 |
site → id | IDはIISExpressが自動採番。 |
site/application → path | site rootからどこに配置するか指定。 |
site/application → applicationPool | アプリケーションプール名。特殊な場合を除いて、変更する必要無し。 |
site/bindings/binding → protocol | プロトコルの指定。http。 |
site/bindings/binding → bindingInformation | 接続許可を指定。『:80:localhost』でPort 80へlocalhostがアクセスできる。 『:80:192.168.1.10』って書くと192.168.1.10:80へのアクセスを許可する。つまりココにIISExpressが動いてるマシンのIP Addressを書いとけばokって話。 |
以上のルールに従って書いてみるとこんな感じ。
e.g.) IIS Expressが動くマシンのIP Addressが『192.168.1.10』の場合
e.g.) IIS Expressが動くマシンのIP Addressが『192.168.1.10』の場合
- <site name="TestSite" id="25">
- <application path="/" applicationPool="Clr4IntegratedAppPool">
- <virtualDirectory path="/" physicalPath="C:\asp.net_test\testsite" />
- <virtualDirectory path="/test2" physicalPath="C:\asp.net_test\testsite2" />
- </application>
- <application path="/api" applicationPool="Clr4IntegratedAppPool">
- <virtualDirectory path="/" physicalPath="C:\asp.net_test\webapi" />
- </application>
- <bindings>
- <binding protocol="http" bindingInformation="*:80:localhost" />
- <binding protocol="http" bindingInformation="*:80:192.168.1.10" />
- </bindings>
- </site>
コンフィグファイルをいじったら、
以下のコマンドを、コマンドプロンプトで実行。IP addressの部分だけIIS Express動かしてるヤツのIPに変えて解釈して貰えればOK。
> netsh.exe http add urlacl url=http://192.168.1.10:80/ user=everyone
後はfirewall。
コントロールパネルを開いて『Windows ファイアウォール』を押下。
ダイアログが表示されたら左のメニューから『詳細設定』を選択して、『セキュリティが強化された Windows ファイアウォール』ダイアログを開く。
コントロールパネルを開いて『Windows ファイアウォール』を押下。
ダイアログが表示されたら左のメニューから『詳細設定』を選択して、『セキュリティが強化された Windows ファイアウォール』ダイアログを開く。
左側に表示されてるツリーから『受信の規則』を右クリックして、『新しい規則』を押下。
『新規の受信の規則ウィザード』が開くので...
『新規の受信の規則ウィザード』が開くので...
『ポート』を選択して、『次へ』押下。


『TCP』の『80』を指定して『次へ』押下。


『接続を許可する』を選択して『次へ』押下。


とりあえず、怖いので『パブリック』のチェックは外して『次へ』押下。


名前に分かりやすいの設定して『完了』押下。


コレで外部のマシンのブラウザから『http://192.168.1.10』とか入れてみると表示できるハズ。
もし繋がらんかったら、上記を見直してみること。
接続がタイムアウトしたら、Firewallで防がれてる。
503返ってきたら、IISExpressを再起動してみる。
再起動は、VisualStudioのデバッグを停止させて、IISExpressを終了、デバッグを開始とすれば良い。
再起動は、VisualStudioのデバッグを停止させて、IISExpressを終了、デバッグを開始とすれば良い。
※IISExpressの終了の仕方
↓こんなアイコンがシステムトレイ内に常駐してたら、設定が反映されてない可能性有り。
↓こんなアイコンがシステムトレイ内に常駐してたら、設定が反映されてない可能性有り。

システムトレイ内のアイコンを右クリックして『終了』を選択すればOK。


更新日: 2015年04月10日 (金) 17時35分40秒