0
0

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 1 year has passed since last update.

NginxによるTCP Proxy

Posted at

はじめに

NginxによるTCP Proxyを構築した際の備忘録。

環境

  • Docker version 20.10.14
  • Docker Compose version v2.20.3

Nginxコンテナの設定

client --> Nginx --> clickhouse という経路でアクセスを試みます。

compose.yaml
services:
  nginx:
    container_name: nginx
    hostname: nginx
    image: nginx:latest
    ports:
      - '9000:9000'
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf

  clickhouse:
    image: clickhouse/clickhouse-server:23.3.8.21
    container_name: clickhouse
    hostname: clickhouse
    restart: always
    ipc: host

nginx.conf の設定は以下の通り。

nginx.conf

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

stream {
    upstream clickhouse-server {
        # コンテナサービス名を指定
        server clickhouse:9000;
    }
    server {
        # リッスンポート
        listen   9000;
        proxy_pass clickhouse-server;
        # allow {許可IP};
        # deny all;
    }
}

コンテナ構築

compose.yaml があるディレクトリで以下を実行する。

docker-compose up -d

もしくは、

docker compose up -d

アクセス確認

curl localhost:9000

とりあえず、繋がっている様子。

Port 9000 is for clickhouse-client program
You must use port 8123 for HTTP.
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?