使用webdevops/php-nginx在Docker中的NGINX中限制_req

edqdpe6u  于 2023-03-29  发布在  Nginx
关注(0)|答案(1)|浏览(389)

我想没有人会准备好为我概述如何在Docker容器中使用webdevops/php-nginx在NGINX中设置limit_req的值。我在React/Laravel应用程序中遇到了非常偶然的速率限制问题,并想尝试调整一些速率限制设置。
webdevops/php-nginx文档的自定义部分建议,要设置“全局配置选项,可以使用目录/opt/docker/etc/nginx/conf.d。对于vhost配置选项,可以使用目录/opt/docker/etc/nginx/vhost.common.conf”。然而,我不确定如何将其带入Docker进程:

docker build --file Dockerfile.prod -t ghcr.io/theotherdy/laravel-xmap-php-nginx:latest .

使用Dockerfile.prod:

FROM webdevops/php-nginx:8.1-alpine
# These ENV variables refer to options in webdevops/php-nginx - https://dockerfile.readthedocs.io/en/latest/content/DockerImages/dockerfiles/php-nginx.html
ENV WEB_DOCUMENT_ROOT=/app/public
ENV PHP_DISMOD=bz2,calendar,exiif,ffi,intl,gettext,ldap,imap,pdo_pgsql,pgsql,soap,sockets,sysvmsg,sysvsm,sysvshm,shmop,xsl,zip,gd,apcu,vips,yaml,imagick,mongodb,amqp
# sets working directory for any future actions
WORKDIR /app
# ie copying from wherever docker is run to WORKDIR
COPY . .  
COPY composer.lock composer.lock
COPY .env.prod .env
# recommended optimization from: https://laravel.com/docs/9.x/deployment
RUN composer install --no-interaction --optimize-autoloader --no-dev
RUN php artisan key:generate
RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan view:cache
# Ensure all of our files are owned by the same user and group.
RUN chown -R application:application .

docker-compose.yml:

version: "3" services:
    app:
        image: ghcr.io/theotherdy/laravel-xmap-php-nginx:latest
        ports:
            - '9000:80'
        volumes:
            - ./storage:/app/storage
        #env_file: '.env'
        depends_on:
            - db
        restart: always
    db:
        image: 'mysql/mysql-server:8.0'
        container_name: xmap-db
        environment:
            MYSQL_ROOT_PASSWORD: 'xx'
            MYSQL_ROOT_HOST: "%"
            MYSQL_DATABASE: 'xx'
            MYSQL_USER: 'xx'
            MYSQL_PASSWORD: 'xx'
            MYSQL_ALLOW_EMPTY_PASSWORD: 0
        volumes:
            - db-data:/var/lib/mysql
        restart: always 
    volumes:
        db-data:

任何建议/指针非常感谢接收!

fcg9iug3

fcg9iug31#

在容器内部,如果导航到/opt/docker/etc/nginx,您将发现以下结构:

vhost.common.d中添加的任何.conf文件都将加载到server上下文中,因此您可以在DockerfileCOPY您自己的文件以添加所需的设置:

FROM webdevops/php-nginx:8.1-alpine
# ...
COPY my-nginx-settings.conf /opt/docker/etc/nginx/vhost.common.d/custom.conf
# ...

如果需要添加全局设置,请在conf.d中添加该文件。

相关问题