1. 참고
링크 : https://github.com/chobits/ngx_http_proxy_connect_module
GitHub - chobits/ngx_http_proxy_connect_module: A forward proxy module for CONNECT request handling
A forward proxy module for CONNECT request handling - GitHub - chobits/ngx_http_proxy_connect_module: A forward proxy module for CONNECT request handling
github.com
2. 버전
- Nginx : 1.24.0
- 패치파일 : proxy_connect_rewrite_102101.patch

3. Dockerfile
FROM nginx:1.24.0
ARG NGINX_VERSION=1.24.0
ARG PATCH_VERSION=proxy_connect_rewrite_102101
RUN apt update \
&& apt install -y \
vim \
wget \
git \
curl \
gcc \
make \
libpcre3-dev \
zlib1g-dev \
libssl-dev && \
rm -rf /var/lib/apt/lists/*
# nginx source 및ngx_http_proxy_connect_module 설치
RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
# nginx 압축해제
RUN tar -zxvf nginx-${NGINX_VERSION}.tar.gz
# ngx_http_proxy_module 설치
RUN git clone "https://github.com/chobits/ngx_http_proxy_connect_module.git"
# ngx_http_proxy_module 패치 및 환경설정
RUN cd nginx-${NGINX_VERSION} && patch -p1 < /ngx_http_proxy_connect_module/patch/${PATCH_VERSION}.patch && \
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.24.0/debian/debuild-base/nginx-1.24.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' --add-dynamic-module=/ngx_http_proxy_connect_module/
# 소스 컴파일 및 설치
RUN cd nginx-${NGINX_VERSION} && make && make install
# 새로운 dynamic module ngx_http_proxy_connect_module 복사
RUN cp /nginx-${NGINX_VERSION}/objs/ngx_http_proxy_connect_module.so /etc/nginx/modules/
# forward proxy 설정 복사
#COPY conf.d /etc/nginx/
#COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80 443 30080 30443
RUN groupmod -g 1002 nginx || true
RUN usermod -u 1002 -g 1002 nginx || true
RUN chown -R nginx:nginx /var/log/nginx /etc/nginx
CMD ["nginx", "-g", "daemon off;"]
4. Nginx 설정 파일
- /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
# 추가
load_module /etc/nginx/modules/ngx_http_proxy_connect_module.so;
...
- /etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
server_name localhost;
# 추가
resolver 8.8.8.8;
proxy_connect;
proxy_connect_allow all;
proxy_connect_connect_timeout 10s;
proxy_connect_read_timeout 10s;
proxy_connect_send_timeout 10s;
...
'인프라 > Docker' 카테고리의 다른 글
lighthouse 성능 보고서 추출 도커 이미지 만들기 (0) | 2024.05.10 |
---|---|
[Docker] 사용자, 그룹을 tomcat으로 하는 커스텀 tomcat 이미지 생성 (Dockerfile) (0) | 2023.12.08 |
[flask + uwsgi] Dockerfile (0) | 2023.04.29 |
Docker Swarm & Tomcat Session Clustering (0) | 2023.02.14 |
Docker Swarm 구축 (0) | 2023.02.12 |