Skip to content

Commit

Permalink
feat: refactor docker http proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
DDSRem committed Jun 7, 2024
1 parent 2d4fb5d commit 48a860b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ RUN apt-get update -y \
busybox \
dumb-init \
jq \
haproxy \
fuse3 \
rsync \
ffmpeg \
Expand Down Expand Up @@ -68,8 +67,9 @@ COPY . .
RUN cp -f /app/nginx.conf /etc/nginx/nginx.template.conf \
&& cp -f /app/update /usr/local/bin/mp_update \
&& cp -f /app/entrypoint /entrypoint \
&& cp -f /app/docker_http_proxy.conf /etc/nginx/docker_http_proxy.conf \
&& chmod +x /entrypoint /usr/local/bin/mp_update \
&& mkdir -p ${HOME} /var/lib/haproxy/server-state \
&& mkdir -p ${HOME} \
&& groupadd -r moviepilot -g 911 \
&& useradd -r moviepilot -g moviepilot -d ${HOME} -s /bin/bash -u 911 \
&& python_ver=$(python3 -V | awk '{print $2}') \
Expand Down
43 changes: 43 additions & 0 deletions docker_http_proxy.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
worker_processes 1;
user root;
daemon on;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
upstream docker {
server unix:/var/run/docker.sock fail_timeout=0;
}
server {
listen 38379;
server_name localhost;

access_log /dev/stdout combined;
error_log /dev/stdout;

location / {
proxy_pass http://docker;
proxy_redirect off;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 120;
proxy_read_timeout 120;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
}
4 changes: 2 additions & 2 deletions entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ chown moviepilot:moviepilot /etc/hosts /tmp
gosu moviepilot:moviepilot playwright install chromium
# 启动前端nginx服务
nginx
# 启动haproxy
# 启动docker http proxy nginx
if [ -S "/var/run/docker.sock" ]; then
haproxy -f /app/haproxy.cfg
nginx -c /etc/nginx/docker_http_proxy.conf
fi
# 设置后端服务权限掩码
umask "${UMASK}"
Expand Down
60 changes: 0 additions & 60 deletions haproxy.cfg

This file was deleted.

0 comments on commit 48a860b

Please sign in to comment.