Articles of nginx

将ASCII百分比编码的位置重写为其UTF-8编码的等效项

例如,“å”可以编码为/%E5和/%C3%A5(utf-8)。 所有我的文件名是UTF-8,所以ASCII变种返回一个404。我希望这两个变种工作。 我试着用不同的下面的configuration将不正确的URL改写成正确的编码。 我没有能够真正匹配的位置,所以没有得到任何地方。 rewrite ^/%E5$ /%C3%A permanent; rewrite ^/%25E5$ /%25C3%25A permanent; location = /%E5 { return 301 /%C3%A; } 我该如何匹配这些百分比编码位置?

nginx:default_server指令不被尊重

我有多个文件,每个都有一个不同的虚拟主机的configuration。 在这些configuration文件之一(包含在主要的nginxconfiguration文件中),我设置了default_server指令: server { listen 80; listen 443 ssl default_server spdy; server_name 188.166.X.XXX; root /var/www/default; index index.php index.html; … } …但不受尊重 如果我指出我没有添加到nginx服务器块的域的Alogging,则按照字母顺序选取第一个服务器块(而不是default_server)。 为什么?

nginx错误日志log_formatvariables

我想为nginx错误日志指定日志格式,但是我找不到任何错误的variables。 我发现访问日志所需的variables如下所示: log_format test'$remote_addr – $remote_user [$time_local] ' '"$request" $status $bytes_sent ' '"$http_referer" "$http_user_agent" "$gzip_ratio"'; 是否有任何$错误,$ error_body或类似的东西,可以匹配的错误?

NGINX在写作状态下积累连接是否正常?

这是一个显示来自nginx的stab_status的连接数的图表,图中的下拉列表是服务器重新手动完成的。 我觉得这种行为很奇怪,看起来有些泄漏。 我认为应该closures的挂钩关系,但他们保持书面状态。 这是正常的吗? 我应该采取行动吗? 如果是这样,在哪个方向? 我试着改变nginx的keepalive,然后像这样的一些内核设置https://gist.github.com/perusio/2154235 但是这种行为并没有改变。 该服务器是一个可用的处理器和1024MB内存的VPS。 编辑1:版本 nginx版本:由gcc 4.8.2构build的nginx / 1.6.2(Ubuntu 4.8.2-19ubuntu1)启用了TLS SNI支持的configuration参数:–add-module = / root / ngx_pagespeed-release-1.9.32.3-beta –prefix = / etc / nginx –conf-path = / etc / nginx / nginx.conf –error-log-path = / var / log / nginx / error.log –http-client-body-temp-path = / var / lib / nginx / body […]

在nginx中添加花括号来映射块

我有一个问题试图让下面的configuration工作。 每次运行configurationtesting时,都会收到失败的通行证。 首先让我给你看一个可行的configuration location / { if ($query_string ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3D)"){ return 403; } } 但是,当我尝试有点聪明,把这个地图块,我得到一个错误 map $query_string $edgars_access_denied { default "200"; ~mosConfig_[a-zA-Z_]{1,21}(=|\%3D) "403"; }

不能在nginx上使用mail(),但可以使用msmtp在控制台上发送邮件

我安装msmtp在我的centos 6,我知道它的工作正常,因为我可以使用bash命令发送电子邮件: echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp –debug –from=default -t [email protected] 那么,我正在继续让nginx也允许使用msmtp ,在我的php.ini这是我的sendmailpath: sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc –logfile /var/log/msmtp.log -a gmail -t" 那么,我试着用这个发送: <?php if(mail("[email protected]","A Subject Here","Hi there,\nThis email was sent using PHP's mail function.")) print "Email successfully sent"; else print "An error occured"; ?> 但是,它一直失败,我开始认为这是因为permission因为没有写在日志中,这里是我有权限 对于msmtprc @ / […]

Nginx的FastCGIcaching可能在自定义url?

我正在尝试使用FastCGIcaching为我的网站构build自定义caching解决scheme。 我试图caching只有某些url,得到一个船载stream量。 我从我的日志中知道哪些URL是,但他们总是在变化。 有没有一种方法可以指定Nginx必须caching的某些URL,但不能caching其他所有内容。 我按照这个教程 ,我caching工作。 但我无法解决如何caching自定义url。 例如说url.com/b.php?q=123。 理想情况下,我会将一个URL列表存储在Nginx加载的.conf文件中,并且只对这些URL使用caching,但不会caching所有其他文件。 这对Nginx可能吗?

(nginx)Apache Forbidden错误(随机):没有错误日志

我正在运行一个Nginx服务器,但是到了最近,我随机得到了Apache的“Forbidden”错误,而且在刷新/浏览一段时间后,似乎永远不会在“第一次”访问时发生。 更重要的是,我的httpd (/var/etc/httpd/logs/error_log and /var/logs/httpd/….) “指定”错误日志是空的。 我想他们应该是空的,因为我正在运行NGINX,但错误是由Apache显示的,所以我想它应该在这里。 但是后来我才知道httpd是不活动的。 我指定的Nginx日志工作。 通过访问我的服务器通过www.example.com (virtual.conf),我看到访问和错误日志。 错误日志显示了一些与此问题无关的随机内容。 通过访问我的网站通过IP(default.conf),我正在获取访问日志,但错误日志是空的。 所以我假设这个问题不是由NGINX引起的,HTTPD是“禁用”的,但是在浏览一段时间之后,我在任何页面上随机出现“Forbidden”Apache错误。 附加信息 我提出了我的硬/软ulimit 166384,重新启动我的服务器等Apache的运行作为根由于某种原因(这是奇怪的,因为我提到, httpd显示为“禁用”)。 Nginx的default.conf(通过IP访问服务器的configuration) server { listen 80; server_name localhost; #charset koi8-r; access_log /var/log/nginx/access2.log main; error_log /var/log/nginx/error2.log warn; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html […]

Codeigniter在Nginx 404的子目录中

我试图在我的域的子目录中设置Codeigniter。 目前我只在索引页面上从Codeigniter获得一个404。 一旦想要去example.com/api/welcome/index我从nginx获得一个404。 我的nginx.conf : location /api/ { alias /var/www/api/; try_files $uri $uri/ /api/index.php =404; location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_pass backend; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } 和Codeigniter.conf : $config['base_url'] = 'https:/example.com/api/'; $config['uri_protocol'] = 'REQUEST_URI'; $config['index_page'] = '';

hhvm + nginx + wordpress – 上传问题

我在数字海洋液滴上安装了nginx 1.7.12 + hhvm 3.7.0 + wordpress 4.2.2。 我正在尝试上传一个17 MB的主题。 上传时,正好30秒后上传重新启动本身3-4次,比我得到一个错误页面。 所有的设置是默认的,我甚至尝试把这个在php.ini(hhvm): max_execution_time = 300 max_input_time = 60 memory_limit = 128M post_max_size = 50M upload_max_filesize = 50M 但没有任何改变。 有什么想法吗?