LoginSignup
1
1

More than 3 years have passed since last update.

localhostのみアクセスできるサービスをnginxで中継する

Posted at

概要

localhost指定でしか応答しないサービスに対しでnginxによる中継を行い、サービスを利用する。
Websocket対応。

環境

  • Windows 10

インストール

http://nginx.org/en/download.html より適当なバージョンをダウンロードし、展開する。

設定ファイル

元の nginx.confnginx.conf.bak 等に名前を変えバックアップ後変更する。

Host の指定をしなければ自動的にアクセス元がnginxホストとなる。

nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''  close;
    }

    server {
        listen       80;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        location / {
            proxy_pass  http://localhost:18080/;
        }
    }
}

参考

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