首页 > 解决方案 > Nginx 允许来自同一个 ip 的多个连接

问题描述

我正在使用“php:7.4-fpm”docker 映像并通过“apt-get install”安装了额外的“nginx”包。

如果客户端通过网页启动长时间运行的脚本,则客户端无法打开另一个页面,直到第一个脚本返回响应。有没有办法允许每个 ip/client 有多个连接?

添加了以下配置:

server {
    server_name ~.*;
    root /usr/src/app/public;

    # Add logging
    error_log /var/log/nginx/error.log warn;
    access_log /var/log/nginx/access.log;

    # Add stdout logging
    error_log /dev/stderr warn;

    # Security - Hide nginx version number in error pages and Server header - dev is ok
    server_tokens on;

    # reduce the data that needs to be sent over network
    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    gzip_types text/plain text/css text/xml application/json text/javascript application/x-javascript application/xml;
    gzip_disable "MSIE [1-6]\.";

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

    # pass the PHP scripts to FastCGI server listening on socket
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
        # fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        fastcgi_param PATH_TRANSLATED $document_root/$fastcgi_path_info;
        fastcgi_buffers 32 32k; # increase the buffer size for PHP-FTP
        fastcgi_buffer_size 64k; # increase the buffer size for PHP-FTP
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 3600;
        fastcgi_read_timeout 3600;
        include fastcgi_params;
    }

    # cache static
    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        access_log off;
        log_not_found off;
        expires -1;
    }

    # deny access to . files, for security
    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }
}

标签: dockernginx

解决方案


推荐阅读