Articles of nginx

PHP-FPM死亡白屏,没有错误logging

这是两个不同的PHP文件的故事。 文件1来源: <?php $null->test(); 文件1输出: 致命错误:在一个非对象中调用成员函数test() /wwwroot/sites/example.com/public/fatal.php在第1行 这也打印到/var/log/php-fpm/www-error.log(在我的www.conf中定义) 文件2: class A {} function test(A $obj) { echo 'here…'; } var_dump('started'); $a = new A(); test($a); var_dump('this is going to error out'); test($null); var_dump('do we get here?'); 文件2输出: string“开始”(长度= 7) 这里… string“这将会出错”(长度= 26) 没有错误logging。 /etc/php-fpm.d/www.conf中的相关设置: catch_workers_output = yesphp_flag [display_errors] =开启 php_flag [display_startup_errors] =开启 php_admin_value [error_reporting] = […]

在Varnish安装后将端口号添加到WordPresspipe理员

我在nginx前面添加了Varnish。 当我尝试login到WordPress,我去domain.com/wp-admin,但我现在redirect到domain.com:8080/wp-admin。 我可以手动删除端口和pipe理端function的方式。 我的清漆configuration: backend origin { .host = "localhost"; .port = "8080"; .connect_timeout = 60s; .first_byte_timeout = 60s; .between_bytes_timeout = 60s; } acl purge { "localhost"; } sub vcl_recv { set req.backend = origin; set req.http.X-Forwarded-For = client.ip; if(req.url ~ "^/wp-(login|admin)" || req.http.Cookie ~ "wordpress_logged_in_") { return (pass); } if(req.url ~ "/xmlrpc.php") { return(pass); […]

使用Nginx作为反向代理的Tomcat应用程序(JIRA)的基本身份validation

我有几个运行Atlassian Tomcat应用程序的子域名(jira.example.com,confluence.example.com,stash.example.com),我想知道是否可以使用.htpasswd用basic_auth对所有这些域进行密码保护。 Nginx的工作正常,没有basic_auth指令,但如果我尝试在nginx.conf这样介绍它… user nginx; worker_processes 1; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load config files from the […]

NGINX / PHP-FPM通过https / SSL访问非常缓慢

从一个星期前开始,我开始注意到我的web应用程序的糟糕performance。 我的应用程序在Amazon EC2 m1.large实例上提供。 只有4-5kb的静态文件通常需要超过10秒才能收到。 这会间歇性地发生,但是对于每一个页面加载,我可以预期至less有一两个特定资源的等待时间。 从检查Firebug很显然,抢劫处于请求的“等待”部分。 (DNS /连接/发送和接收总是很好) 不幸的是,我还没有发布图片所需的信誉,或者我会。 更糟糕的是,当一个页面请求大量的静态资源,比如Images时,几乎每一个请求都会出现这个问题。 玩过我的NGINX和PHP-FPMconfiguration后,在上个星期左右,我才发现只有在通过HTTPS访问服务器时,问题才出现。 使用ab命令testing性能时可以看到这一点。 HTTPS: ab -c 100 -n 3000 https://www.mydomain.com/ Server Port: 443 SSL/TLS Protocol: TLSv1,RC4-SHA,2048,128 Document Path: / Document Length: 13367 bytes Concurrency Level: 100 Time taken for tests: 12.122 seconds Complete requests: 3000 Failed requests: 0 Write errors: 0 Total transferred: 41205000 bytes […]

随着SPDY的推动,是否有任何点在远期到期头文件?

据我了解,在SPDY推送服务器提供一个HTML文档,发送之前,它看,并决定我需要图像/ CSS资源XY和Z,所以也发送它们。 它是如何知道不打扰,如果他们已经被我的浏览器caching? 或者,如果客户端使用spdy / 3浏览器,试图caching静态资源基本没有意义? (显然不是每个客户都会,但我对这个案子感兴趣)

nginx gzip_static:为什么需要非压缩文件?

我正在使用在Ubuntu 12.04.4上运行的nginx 1.4.4 。 nginx是一个Rails应用程序服务器集群的反向代理。 静态文件(主要是资产)直接提供,而不会击中应用程序服务器。 我已经将其设置为gzip响应,并在可用时使用预压缩文件。 http { gzip on; gzip_http_version 1.0; gzip_proxied any; # other ngx_http_gzip_module directives… server { # proxy configuration location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; # root is inherited try_files $uri =404; error_page 404 /404.html; } } } 这工作。 我已经使用真正的预压缩资产和名称相同但内容不同的虚拟非压缩资产进行了testing: /assets/application-a45d6…e2593.css # dummy content /assets/application-a45d6…e2593.css.gz […]

所有的Laravel路由在nginx上都没有find

试图在nginx服务器(第一次)上安装Laravel 4.1安装程序,并且我为每个Laravel路由而不是预期的视图提供“未find”。 主页面加载正常。 请注意,网站只能通过IP访问,这就是为什么我的填充IP为123.123.123.123 server_name 。 等/ nginx的/ nginx.conf: listen 80; user nginx; worker_processes 4; worker_rlimit_nofile 200000; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 4000; use epoll; multi_accept on; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; […]

将所有TLD请求转发到其他服务器

所以,紧急情况已经降落在我的腿上,不幸的是我没有足够的处理能力。 一家客户公司的IT技术改变了一个域名的Alogging,然后去度假。 他是唯一一个可以进入的人,在丛林中再次出现之前,没有办法改变它。 他应该只是指出www. 一个logging到一个新的IP,指向我们的服务器托pipemysite.com – 然而,他改变了* Alogging到新的IP – 这意味着所有的子域现在已经死亡( mail. , exchange. , secure.等) 。 最初的* Alogging指向另一个分开处理所有子域请求的服务器。 虽然我无法访问DNS控件,但是我可以完全访问DigitalOcean服务器和控制面板,以* Alogging现在指向的位置。 在DigitalOcean服务器上,我可以通过DNS控制面板(尽pipe看起来不那么一目了然)或通过virtual.conf文件(参见下文)来正确转发任何请求(即, mail.mysite.com )到正确的IP,然后应该正确处理请求? 作为参考,服务器是运行nginx的CentOS 6.5 x64。 当前处理传入请求的服务器块如下所示: server { listen 80; server_name mysite.com www.mysite.com; root /var/www/html/mysite.com/; error_page 403 404 500 502 503 504 = /server_error.php; index index.php index.html index.htm; location / { try_files $uri $uri/ […]

我可以删除nginx client_body_temp目录中的文件吗?

在我的nginx服务器上,我无法login到我的WordPress的网站。 错误日志提到“设备上没有剩余空间”。 2014/9/26 02:02:05 [crit] 1197#0:* 32 open()“/ usr / local / nginx / client_body_temp / 0030999742”失败(28:设备上没有剩余空间) 有空间,但我发现我的inode使用率是100% 我已经追踪到/usr/local/nginx/client_body_temp文件数量太多,因为有太多的文件需要统计。 所以我的问题是:这个目录是什么,我可以删除这些文件?

Nginx:将http和https根redirect到子目录

我试图redirect在nginx中的http和https的根域到相同的子目录(https): 所以,例如 http://example.com -> https://example.com/subdirectory https://example.com -> https://example.com/subdirectory 我觉得这很简单,我正努力做到这一点。 我试过使用重写的变体,并返回301,但总是以redirect循环结束。 我当前的configuration(导致循环): server { listen 80; server_name example.com; return 301 https://$server_name/subdirectory; } server { listen 443 ssl spdy; server_name example.com; return 301 https://$server_name/subdirectory; } 所以基本上,我试图redirect到https域根目录上相同的子目录,无论是通过http或https请求根域。