chore(docker): 支持独立的WebSocket 服务暴漏

This commit is contained in:
2025-12-19 18:04:29 +08:00
parent ba5c2239ac
commit f8291dd2ba
5 changed files with 19 additions and 7 deletions

View File

@@ -1,7 +1,14 @@
location /ws { location /ws {
proxy_pass http://php-fpm:8080; proxy_pass http://php-fpm:8080; # 注意:这里用的是 Docker 服务名或容器名
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 可选设置超时WebSocket 是长连接)
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
} }

View File

@@ -20,13 +20,13 @@
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; # add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# --- SSL configuration end --- # --- SSL configuration end ---
# 启用 WebSocket 支持
include conf.c/enable-websocket.conf;
#PHP-INFO-START PHP引用配置可以注释或修改 #PHP-INFO-START PHP引用配置可以注释或修改
include conf.c/enable-php-74.conf; include conf.c/enable-php-74.conf;
#PHP-INFO-END #PHP-INFO-END
# 启用 WebSocket 支持
include conf.c/enable-websocket.conf;
# --- REWRITE-START --- URL重写规则引用,修改后将导致面板设置的伪静态规则失效 # --- REWRITE-START --- URL重写规则引用,修改后将导致面板设置的伪静态规则失效
# include /www/server/panel/vhost/rewrite/xcx30.5g-quickapp.com.conf; # 等于下面的内容 # include /www/server/panel/vhost/rewrite/xcx30.5g-quickapp.com.conf; # 等于下面的内容
location / { location / {

View File

@@ -28,8 +28,13 @@ RUN apt-get update && apt-get install -y \
libjpeg62-turbo-dev \ libjpeg62-turbo-dev \
libpng-dev \ libpng-dev \
iputils-ping \ iputils-ping \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# 安装 WebSocat 完成后,清理缓存
COPY ./websocat /usr/local/bin/websocat
RUN chmod +x /usr/local/bin/websocat
# 安装 PHP 扩展 # 安装 PHP 扩展
RUN docker-php-ext-configure gd --with-freetype --with-jpeg \ RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install \ && docker-php-ext-install \

View File

@@ -47,7 +47,7 @@ startsecs=3
stopwaitsecs=10 stopwaitsecs=10
[program:websocket-server] [program:websocket-server]
command=php src/ws_server.php command=php ./ws_server.php
workdir=/var/www/html workdir=/var/www/html
autostart=true autostart=true
autorestart=true autorestart=true

BIN
docker/php/websocat Normal file

Binary file not shown.