我有一个脚本,显示图像,我试图从limit_req排除下面的PHP路线 rewrite ^/([^\@]*)\@(\d+x\d+)$ /index.php?route=image&action=show&path=$1&size=$2 break; 我有 location ~ .php$ { limit_req zone=req_limit_per_ip burst=3 nodelay; limit_conn conn_limit_per_ip 3; include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.1-fpm.sock; } 为我使用的图像和其他文件格式 location ~* ^.+.(jpg|jpeg|gif|png|svg|ico|css|less|xml|html?|swf|js|ttf)$ { expires 10y; } 所以如何从nginxconfiguration中的limit_req中排除路由(index.php?route = image)?
更新:这适用于Firefox,但不适用于Chrome。 这可能是一个浏览器caching问题? 我有一个configuration为使用SSL的网站。 以下是我用于本网站的Nginxconfiguration文件的一部分: server { listen 80; listen [::]:80; server_name ccrs.co.in www.ccrs.co.in; return 301 https://ccrs.co.in$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/ssl-ccrs.co.in.conf; include snippets/ssl-params.conf; server_name www.ccrs.co.in; return 301 https://ccrs.co.in$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; include snippets/ssl-ccrs.co.in.conf; include snippets/ssl-params.conf; server_name ccrs.co.in; root /home/ankush/wp_ccrs/; […]
根据这个模式,我为一个有限的广播公司configuration了一个简单的直播服务: 实际的服务configuration 有一个“起源”服务器,我已经安装了NGINX和RTMP模块。 该服务器接收RTMPstream并将其转换为不同大小(360p,720p)的HLS。 networking服务器仅托pipe重现这些HLSvideo的网站。 我打算大幅增加广播公司,为了确保所有来源的正确处理,我想改进服务器configuration。 在networking上,我发现很less的信息,我假设这种configuration: 做服务configuration “原始”服务器将只接收RTMPstream。 两台或多台“边缘”服务器从原点提取数据并将其转换为HLS格式(多种分辨率)。 networking服务器仅托pipe重现这些HLSvideo的网站。 我的问题是:1.所有“边缘”服务器必须以多种分辨率将RTMPstream转换为HLS格式? 或者一个边缘服务器可以将RTMPstream转换为HLS 360p,而其他边缘服务器可以将RTMPstream转换为HLS 720p? 在RTMP-HLS转换之后,HLS 360p文件必须存储在存储HLS 720p文件的同一台服务器上? 从Web服务器播放video足以在边缘服务器和Web服务器之间引入平衡节点?
Nginx与PHP的FPM – 资源暂时不可用 – 502错误 我正在使用一些代码来发送超过160 GET请求asynchronous使用curl到我的API,这是在Ubuntu服务器16.04运行Nginx的Php-fpm。 每个请求在将其作为JSON响应返回之前,从数据库中提取不同的数据select。 这个请求的数量足够小,我相信它不应该达到各种默认限制(套接字连接数,文件描述符等)。 然而,他们全部被发送/同时收到的事实似乎是造成问题。 绝大多数请求都会成功 ,但是一对(连续testing中一致的号码,但根据configuration不同)会得到一个“502错误的网关”响应。 如果我看看nginx错误日志( /var/log/nginx/error.log ),我看到这些错误消息: 2017/11/21 09:46:43 [error] 29#29: *144 connect() to unix:/run/php/php7.0-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 192.168.3.7, server: , request: "GET /1.0/xxx HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "my.domain.org" 日志中的“502错误网关”错误消息的数目总是与我从API收到的完全一样。 同时,在执行testing期间( tail -100f /var/log/php7.0-fpm.log )观察fpm日志文件时,没有任何反应。 它只是有以下几点: [21-Nov-2017 11:54:29] NOTICE: fpm […]
我正在将一个编译的CGI从IIS移植到Nginx,该应用程序使用自定义错误404来执行Url重写和静态文件caching,在IIS中这个工作 <httpErrors> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/index.exe" responseMode="ExecuteURL" /> </httpErrors> 它将request_uri传递给index.exe,然后像这样 example.com/users 在内部处理为 example.com/index.exe?module=users 或类似的东西 example.com/blog/my-first-post.html 被处理为 example.com/index.exe?module=blog&postname=my-first-post 在Nginx的我想这个(在另一台服务器上的后台运行的CGI) server { listen 80; server_name example.com; root E:/domains/example.com; index index.html index.htm default.html default.htm; location ~* ^\/.* { proxy_pass http://localhost:5001; } } 但是,如果我进入example.com/users我得到一个403错误… 请任何帮助将感激:)
让我asume我的环境如下: 客户端(Apache的Jmeter负载testing) nginx(docker container runnning nginx:1.12.2) (Docker容器运行embedded式的wild:群:1.2.9) 目前我正在尝试configurationnginx并承诺允许700个并发用户。 负载testing(客户端)以700个并行线程运行,每个线程执行50个请求。 这个请求将会被返回一个简单的JSON的ows / wildfly-swarm服务。 整个环境运行在我的本地设备(之间没有缓慢的networking)。 docker集装箱在他们自己的dockernetworking中运行,并且容器之间的链接使用docker容器名称(正确地parsingdocker容器IP)。 情况1 [client] –> [undertow] 所有的请求被送达。 运行wildfly / undertow的容器似乎能够服务于负载testing(客户端)的请求。 情景2 [client] –> [nginx] –> [undertow] 用下面的configuration将nginxconfiguration为反向代理。 worker_processes 2; events { worker_connections 1024; use epoll; } http { access_log off; error_log /var/log/nginx/error.log; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; tcp_nodelay on; upstream undertow_upstream { […]
我正在尝试configuration一个Magento商店快速闪电,所以我想configuration清漆caching。 testing显示1ms请求和10ms响应是完美的。 然而,商店需要sslconfiguration。 目前的configuration是Varnish – > Apache。 我build立了SSL终止工作,但请求时间立即射击了大约400ms。 然后我尝试使用Nginx将https请求传递给清漆,结果类似。 只有我能想到的是完全切换到NGINX,但我完全猜测,希望在这里的一些build议。 这可以configuration为有更快的请求时间,类似于最初经历的1ms? UPDATE 用Firefoxtesting显示不错的13ms请求时间不知道为什么Chrome是如此之慢。 这只是一个自我签名证书的开发目的,并显示不安全的铬我想知道这是否可能是一个问题在这里。 Apacheconfigurationtesting: <VirtualHost *:443> ServerName test.domain.com ProxyPreserveHost On ProxyPass / http://127.0.0.1:80/ RequestHeader set X-Forwarded-Port "443" RequestHeader set X-Forwarded-Proto "https" SSLEngine On SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key #SSLCertificateChainFile /etc/apache2/ssl/example.com.chain </VirtualHost> 可选的Nginxconfiguration: server { listen *:443 ssl; server_name test.domain.com; ssl on; ssl_certificate /etc/ssl/certs/apache-selfsigned.crt; ssl_certificate_key /etc/ssl/private/apache-selfsigned.key; […]
服务器pipe理是绝对不是我的域名 – 不幸的是,我坚持build立一个服务器,有nginx作为静态资产服务器和Apache后面用php-fpm服务的PHP页面。 即时尝试获得代理cachingbuild立,它只适用于我不使用PHP会话。 我可能会错过这里一点,但在我的理解,我不明白为什么caching不应该提供一个标准的PHP会话cookie不用于身份validation? 所以我认为它是一个configuration问题,但我用这一个敲我的头。 我在这里发布我的设置 – 希望有人可以让我在正确的方向。 我有一个PHP文件没有别的,但: session_cache_limiter('public'); ini_set('session.cache_expire', 1000); session_start(); echo "OK"; die(); nginx.conf: user www-data; worker_processes 6; worker_rlimit_nofile 50000; pid /run/nginx.pid; events { worker_connections 8096; multi_accept on; use epoll; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; types_hash_max_size 2048; server_tokens off; # […]
我有一个安装程序,其中有数千个图像存储在以数字范围(1-10000,10001-20000,20001-30001等)命名的目录中。 所以例如我的url是https://www.example.com/images/123456/example-image-01.jpg 但我的实际文件位于/var/www/contents/120001-130000/123456/123456.jpg 完全匹配我的位置块将是: location = /images/123456/example-image-01.jpg { rewrite ^/images/(.*)/(.*)$ /var/www/contents/120001-130000/$1/$1.jpg break; } 但有没有办法做到这一点与location ~*正则expression式匹配,让Nginx的图像名称不带URL后缀( 123456 ),并将其转换到相应的范围( 120001-130000 )?
几天后,我仍然试图限制除了一个请求。 我想排除包含“上传”的url,但我收到以下错误:nginx:[emerg]“limit_req”指令不允许在这里 location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.1-fpm.sock; if ($request_uri !~ "uploads") { limit_req zone=req_limit_per_ip burst=3 nodelay; limit_conn conn_limit_per_ip 3; } }