gpt4 book ai didi

php - Nginx和php-fpm-主机无法访问

转载 作者:行者123 更新时间:2023-12-02 20:04:48 25 4
gpt4 key购买 nike

我有包含一个nginx和一个php-fpm服务的docker swarm。我的问题是,从swarm的其他服务中,我随机获得错误Failed to connect to nginx-fpm port 8081: Host unreachable

nginx和fpm镜像来自官方docker镜像,几乎没有配置更改。

nginx-fpm jetty 文件

FROM nginx:1.13.12-alpine

COPY ./nginx/config/ /etc/nginx/
ADD ./nginx/docker/entrypoint.sh /bin/

EXPOSE 8081
ENTRYPOINT ["/bin/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

Nginx配置
user  nginx;
worker_processes auto;

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


events {
accept_mutex on;
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

keepalive_timeout 65;

server {
listen 8081;
server_name worker;

keepalive_timeout 30;
send_timeout 30s;
fastcgi_read_timeout 30s;
client_max_body_size 1024M;

root /app/www;
index index.php;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
}
}

我尝试了启用nginx_status的事件,但只能看到1个 Activity 连接(或主机不可达)。

在我看来,nginx一次只能处理一个连接,但是我找不到原因……任何帮助表示赞赏

最佳答案

您如何在Swarm中运行服务?

通常,您需要在外部公开服务端口,如下所示:

$ docker service create --name my_service \
--replicas 3 \
--publish published=8081,target=8081 \
nginx-fpm

关于php - Nginx和php-fpm-主机无法访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50708083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com