Articles of nginx

nginx的try_files索引冲突

我试图用nginx来实现一个设置: 使用index.html作为'/' 清理.htmlurl 如果找不到相应的文件,默认为404 我的服务器块看起来像这样: server { listen 80; server_name 127.0.0.1; index index.htm; location / { root "static"; try_files $uri.html =404; } } 现在,访问“/”到404。我尝试了一些常见的解决scheme,如: try_files $uri.html $uri/ =404; 但这些允许'/ page'和'/page.html'作为有效的url,我想避免重复。 有什么build议么? 谢谢, 加布里埃尔

宕机前的错误消息:posix_memalign(16,4096)失败(12:无法分配内存)

我有一台运行在Gunicorn和Nginx之上的Django服务器,昨天晚上我经历了一小段时间的停机。 重新启动Nginx和Gunicorn后,服务器恢复正常,但我无法弄清楚是什么导致了中断。 检查日志概述了问题发生的地方:首先,大约有100行: 2014/03/04 15:48:47 [emerg] 21790#0: *19536658 posix_memalign(16, 4096) failed (12: Cannot allocate memory), client: xx.xx.xx.xx, server: www.mysite.com, request: "GET /static/images/loading.gif HTTP/1.1", host: "www.mysite.com" 然后,实际的错误来了。 这其中约有300个: 2014/03/04 15:49:04 [error] 21790#0: *19532341 connect() failed (110: Connection timed out) while connecting to upstream, client: xx.xx.xx.xx, server: www.mysite.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "www.mysite.com" …和其中约100个: […]

Nginx允许返回404

根据我的访问日志来看,每当用户加载网站的pipe理页面时,我的网站都会点击“GET / admin / HTTP / 1.1”。 我想将一些IP列入白名单,因此我添加了以下规则: location /admin/ { allow $whitelistIP; deny all; } 这似乎从第三方访问时正确地返回403,但是当被特权方访问时,返回404页面。 如果我完全禁用此节,则返回访问权限,各方都可以再次加载pipe理站点。 因此,我想知道为什么一个404被退回给特权方,当所有的节都允许一个IP …

仅当在Fedora 20上作为系统服务运行时,才会出现PHP-FPM错误(未find文件/未find主脚本)

我试图在Fedora 20盒子上用PHP-FPM设置NGINX, 只有当启动php-fpm作为系统服务时,我才得到“File not found / Primary script unknown”错误。 我在默认的fastcgi.conf中使用了NGINX的默认设置。 (使用: fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; ) 这里是相关的nginx.conf: root /var/www/index; index index.html index.php index.htm; location ~ \.php$ { try_files $uri = 404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi.conf; } 现在,当我直接从shell(以root身份)启动php-fpm时,一切正常,但是当我使用systemctl start php-fpm.service fpm systemctl start php-fpm.service我得到“文件未find/主脚本未知”错误。 这里是php-fpm.service的定义: [Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target [Service] Type=notify […]

APACHE / NGINX对Apache Benchmarktesting进行微调

我需要了解一些有关APACHE / NGINX的调整configuration。 我在VirtuaBox上使用Ubuntu Server 12.04.4 LTS,有两个虚拟机:一个使用APACHE 2.2.22,另一个使用NGINX 1.1.19。 另外我安装了PHP 5.3和MySQL 5.5.35。 我需要使用AB Bench在本地网站上进行一些testing。 特别是,我希望使100000连接的并发性从100到1000,禁用连接KeepAlive选项。 我唯一能做的就是禁用KeepAlive并增加NGINX中的连接数量。 但是我发现增加并发数超过100个的困难。 在apache2.conf中我只禁用了KeepAlive。 经过这样的testing: ab -n 100000 -c 1000 http://www.mysite.com/ 错误是: apr_socket_recv: Connection reset by peer (104) 在nginx.conf中我只设置: worker_connections 100000; keepalive_timeout 0; testing完成了大量的“失败请求”和“非2xx响应”。 在这两种情况下,我认为我发现并发度为100的好结果。我怎样才能更好地调整这两个Web服务器? 提前致谢,

Nginx下载文件而不是执行php

nginx服务器正在下载php文件而不是执行它们 我尝试了每个周围发布的解决scheme 大部分人都有位置问题 但是我的已经没有注释了 我的默认conf文件 server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/www; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name test.com; location / { # First attempt to serve request as file, then # as […]

监控与munin的nginx-plus虚拟主机交通

我正在使用nginx-plus(您必须支付的版本),我想通过vhost监视访问。 当我使用nginx的免费版本,我可以很容易地监控与项目 munin插件访问: 我迁移到nginx plus,我没有数据。 当我将netcatlogin到munin节点时: $ nc localhost 4949 # munin node at servername.com fetch byprojects_access controlcenter.value 0 static.value 0 ccapi.value 0 tracking.value 0 reco.value 0 主要的区别是我login到文件时通过系统日志logging。 每个虚拟主机logging一个标签,这里的标签nginxreco : access_log syslog:server=localhost,facility=local7,tag=nginxreco,severity=info; 我在哪里有免费的nginx下面的日志文件configuration: access_log /var/log/nginx/reco-access.log; 所以,例如对于reco主机,我不得不调整插件configuration: 'reco' => [ {'path' => '/var/log/nginx/reco-access.log'} ], 至 'reco' => [ {'path' => '/var/log/local7.log', 'regex' => 'nginxreco'} ], 由于我使用系统日志,日志格式改变了一点:它添加了一个date,一个主机名和一个标记(这是syslog的login方式) […]

nginx无法find两层深的cgi

通常,我想在http://mysite.com/和任何其他目录请求时提供index.html文件。 以下是在nginx.conf中为/test所做的: location /test { try_files $uri.html $uri/index.html /index.html =404; } 如果我想通过cgi(在thttpd上)从同一个位置提供文件,这也是可以的,提供一个cgi编程页面: location /test { proxy_pass http://127.0.0.1:8000; } 我遇到的问题是如何进入更深层次,比如/ test / page1。 如果page1.html存在,我想要的服务,但是,如果没有,我希望它去到thttpd服务器,并在那里运行的CGI程序。 configuration文件中的许多变化我试过给我一个redirect循环或找不到文件或从服务器错误。 其他时候,我可以得到它服务的CGI和HTML文件,但试图访问目录给出了一个循环。 下面也工作,部分,但我很努力尝试不同的变化,我已经迷失了自己。 location /test { proxy_pass http://127.0.0.1:8000/test; } 我确信只有一个简单的,基本的东西我错过了。

清漆+ Nginx + WordPress:使用清漆get的redirect循环

我有两个使用Wordpress和Nginx的网站,并试图把Varnish放在前面,但是当把Nginx的监听端口改为8080时,所有网站都进入redirect循环。 在启用的网站,我有所有不同的主机分开的文件,因此: server { server_name xpto.xyz.com; root /usr/share/nginx/www/xpto.xyz.com; include global/common.conf; include global/wordpress.conf; } 在common.conf中,我已经configuration了要听的端口。 在光油方面,我有以下清漆文件: DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,256m" 而在default.vcl中有: backend default { .host = "127.0.0.1"; .port = "8080"; } # Drop any cookies sent to WordPress. sub vcl_recv { if (!(req.url ~ "wp-(login|admin)")) { […]

Codeigniter URL仅适用于默认路由器

我已经在这个configuration上在Nginx上安装了Codeigniter: server { listen 80; server_name myserver; root /usr/share/nginx/html; index index.php index.html index.htm; error_log /var/log/nginx/localhost.error_log debug; location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires max; log_not_found off; } location / { try_files $uri $uri/ /index.php?/$request_uri; location = /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/$fastcgi_script_name; include fastcgi_params; } } location ~ /\.ht { deny all; } } 我也用这种方式改变了ceodeignigter的configuration: … […]