nginx 에이전트 udp

2987 단어 Linux
nginx 는 udp 나 tcp 를 지원 하 는 에이전트 나 부하 균형 입 니 다.stream 모듈 을 통 해 udp 를 지원 합 니 다.
우선 컴 파일 과정 에서 stream 모듈 을 열 어야 합 니 다:
./configure --prefix=/usr/local/nginx --with-pcre=/home/temp/nginx/pcre-8.32 --with-zlib=/home/temp/nginx/zlib-1.2.8 --with-openssl=/home/temp/nginx/openssl-1.0.1i --with-http_ssl_module --with-stream

그리고 프로필 에 udp 설정 을 추가 합 니 다:
stream {
    upstream dns_upstreams {
        server 192.168.136.130:53;
        server 192.168.136.131:53;
    }


    server {
        listen 53 udp;
        proxy_pass dns_upstreams;
        proxy_timeout 1s;
        proxy_responses 1;
        error_log logs/dns.log;
    }
}
이렇게 되면 nginx 는 두 서버 의 udp 부하 가 됩 니 다.
마지막 으로 nginx dockerfile 을 첨부 합 니 다.
FROM ubuntu:14.04
MAINTAINER redstarofsleep "*@*.com"
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak
WORKDIR /etc/apt
RUN touch sources.list
RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted universe multiverse" >> sources.list
RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted universe multiverse" >> sources.list
RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse" >> sources.list
RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse" >> sources.list
RUN echo "deb http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse" >> sources.list
RUN echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty main restricted universe multiverse" >> sources.list
RUN echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-security main restricted universe multiverse" >> sources.list
RUN echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse" >> sources.list
RUN echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse" >> sources.list
RUN echo "deb-src http://mirrors.ustc.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse" >> sources.list
RUN apt-get update
ADD nginx-1.12.1.tar.gz /home/temp/nginx
ADD openssl-1.0.1i.tar.gz /home/temp/nginx
ADD pcre-8.32.tar.gz /home/temp/nginx
ADD zlib-1.2.8.tar.gz /home/temp/nginx
RUN apt-get install -y g++
RUN apt-get install -y make
WORKDIR /home/temp/nginx/nginx-1.12.1
RUN ./configure --prefix=/usr/local/nginx --with-pcre=/home/temp/nginx/pcre-8.32 --with-zlib=/home/temp/nginx/zlib-1.2.8 --with-openssl=/home/temp/nginx/openssl-1.0.1i --with-http_ssl_module --with-stream
WORKDIR /home/temp/nginx/nginx-1.12.1
RUN make
WORKDIR /home/temp/nginx/nginx-1.12.1
RUN make install
EXPOSE 80
EXPOSE 9002/udp
ENTRYPOINT /usr/local/nginx/sbin/nginx && /bin/bash

전재 출처 를 밝 혀 주 십시오:http://blog.csdn.net/redstarofsleep

좋은 웹페이지 즐겨찾기