Articles of nginx

NGINX – 404redirect不工作,返回一个错误代码500

我最近设置了NGINX,并且必须实施各种redirect来pipe理我们旧网站中仍然返回Google(以及其他各种链接页面)的页面。 其中一些链接,我们必须redirect到明确的位置,但其余的应该被redirect到根目录/。 我被要求将404,500和501页面redirect回根目录。 我认为这将是相当容易实现使用error_page指令。 我的服务器块包含以下内容 error_page 404 500 501 = @redir; location @redir { rewrite .* / redirect; } 在我的日志文件中,当我请求随机不存在的文件时,我看到以下内容 xxxx – – [02/Mar/2012:11:25:42 +0000] "GET /fgfg.jpg HTTP/1.1" 500 799 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11" 现在提出两个问题: 为什么这会返回500错误,而不是404? 为什么500错误是由error_page部分处理的? 这是整个服务器块 server { listen xxxx:80; server_name www.blah.com; access_log /var/www/www.blah.com/log/access.log; error_log […]

Chrooting NGINX而不是PHP的好处/缺点

我最近chrooted NGINX,它运作良好,但我有麻烦chroot的PHP和MySQL一起,它真的nessasery? 这里有什么好处/坏处呢?

nginx服务.php作为静态文件

好吧,再次显然是一个完全荒谬的问题,我似乎无法弄清楚。 nginx保持服务我的.php文件作为静态文件。 我已经通过ubuntu上的仓库安装了nginx。 我已经安装了php5-fpm(没有configuration改变),都已经重新启动。 我所拥有的设置是尽可能与我的笔记本电脑上的设置相同,并在那里运行。 我甚至设置了像笔记本电脑一样的文件权限,但仍然无济于事。 所以这里是我的网站可用/默认文件 server { #listen 80 default; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /home/johnny/*****; #replaced for privacy's sake index index.html index.htm; expires 0; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt […]

文件/video服务 – 服务器群集configuration

我目前有5台服务器。 1台服务器作为主服务器,存放所有video文件,另外4台服务器使用rsync从主服务器复制并提取video。 video通过HTTP通过nginx伪stream传送。 我想问的是如果有更好的方法呢? 如果一个特定的服务器只保存该文件会更好吗? 例如:file1.mp4将不会被复制到所有的服务器上,只会保留在一台服务器上? 这种方法会减轻IO负载吗? 因为现在,观看者在观看video时被随机地转发到任何这些服务器。 由于所有这些服务器都拥有相同的文件,因此我认为需要花费时间来search,因为每个video都有近13000个video。 另外,是否有调整TCPIP / sysconf优化这个video服务? 服务器configuration: 所有的服务器都configuration了raid 10 4x2TB 12GB的内存。 1GBPS未计量(100tb.com) CentOS的 Nginx伪stream媒体

使用php-fpm时修剪nginx错误日志

从Apache(mpm prefork)转换到php5-fpm的Nginx,我发现错误日志不愉快的parsing。 例如Nginx会产生这样的东西(具体的编辑): 2012/03/12 09:56:59 [error] 22075#0: *432 FastCGI sent in stderr: "PHP Warning: require_once([somefile]): failed to open stream: No such file or directory in [sourcefile] on line 6 PHP Fatal error: require_once(): Failed opening required '[somefile]' (include_path='.:/usr/share/php:/usr/share/pear') in [sourcefile] on line 6" while reading response header from upstream, client: [ip], server: [host].*, request: "GET […]

将HUP发送给Nginx,导致永不老的主进程

有时候,当我尝试通过发送HUP到Nginx来进行优雅的重启时,我终于得到了一个永不停息的主进程,它永远停留,最终我的应用程序变得没有响应,我必须重新启动。 从来没有多余的工作进程。 这并不总是发生,我不知道如何可靠地重现。 我正在用Phusion Passenger运行Nginx。

nginxconfiguration无法find上传模块的configuration,而它绝对存在?

我试图从源码安装nginx,包括nginx上传模块。 不过,我跑到这个奇怪的错误: ./configure –with-http_ssl_module –with-http_flv_module –with-http_gzip_static_module –with-mail –with-mail_ssl_module –with-poll_module –with-http_stub_status_module –with-http_perl_module –add-module=/root/dls/nginx_upload_module_2.2.0 … **adding module in /root/dls/nginx_upload_module_2.2.0 ./configure: error: no /root/dls/nginx_upload_module_2.2.0/config was found** 而configuration是绝对有的: root@xxxxx:~/dls/nginx-1.1.14# l -alh /root/dls/nginx_upload_module-2.2.0/config -rw-r–r– 1 1000 1000 188 2010-09-27 14:54 /root/dls/nginx_upload_module-2.2.0/config 我怎样才能解决这个问题来获得nginx安装?

Nginx + SSL + Rails + Juggernaut(Node.js)+ Engineyard

我在同一台服务器上有两个不同的应用程序。 其中一个在80端口(mydomain.com)上运行,另一个在端口443(sub.mydomain.com)上运行,并具有通配符证书。 第一个应用程序仅用于信息目的,不需要websockets支持。 第二个应用程序应该有安全的websockets支持(wss协议)。 我尝试在engineyard云上为我的rails应用程序和nginx服务器设置juggernaut gem(用于websockets),但是我遇到了一个问题。 Engineyard云只提供两个打开的端口:80和443.我知道nginx并不完全支持http 1.1反向代理,所以我不能使用nginx中的代理redirectwebsockets请求到特定的本地端口(在我的情况下,这个端口是8080)。 我试过使用HAProxy,它对我来说只是使用不安全的websocket,但是我需要支持安全的websocket。 正如我所知,在这种情况下,我应该使用像隧道隧道我的https请求,而不是使用HAProxy,但是当我testing它 – 我看到服务器必须工作几次慢,我仍然没有工作,使用安全套接字连接:( 也许我做错了什么? 也许有人会告诉如何为多个应用程序设置nginx(其中一个应该通过https工作),并使用两个端口(80和443)来保护websocket。 ps另外我用了一个node-http-proxy,在这种情况下,我可以为不同的nginx应用程序设置代理,但是我不能运行websockets(只发生在通过nginx的“handshake”上,而不是“切换协议”)

nginx防热插拔configuration

我很怀疑nginx能不能: 检查if content-type == "image/x-jpeg" || content-type == "image/png" || content-type == "image/gif" if content-type == "image/x-jpeg" || content-type == "image/png" || content-type == "image/gif" If true && referrer != "mysite.com" && referrer != "": 返回404结果或我select的图片。 更新:这是重复的。 但我找不到( 重复 ),直到我张贴。 所以我把这个留给别人

如何在条件下重写nginx不存在的文件?

对于一个成熟的网站,我只需要生成一个缩略图,使用timthumb,将缩略图放在/ thumbs /中。 try_files $uri ^thumbs/(.*)$ /thumb.php?w=290&q=90&src=../full/%1 last; 我怎样才能解决这个问题? 工作Apache代码: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} ^/thumbs/(.*)$ RewriteRule ^(.*)$ /thumb.php?h=90&q=90&src=../full/%1 [NS,L] 提前致谢 :)