Articles of nginx

301redirect多个服务器和DNSlogging

目前我的博客是在blog.domain.com托pipe,并在LAMP堆栈上运行并运行wordpress。 这是我有blog.domain.com DNSlogging指向的地方。 我也有一个nginx服务器上的domain.com托pipe,并将运行我的电子商务应用程序(magento)。 domain.com在这里提供了一个logging点。 出于安全原因,我们将这两个应用程序都放在服务器上。 由于seo的原因,我想将博客移到domain.com/blog。 我所做的是用nginx设置一个反向代理作为apache / wordpress后端的前端caching。 所以这工作很好,我注意到caching实际上改善了我的加载时间。 现在我需要将所有的blog.domain.com请求redirect到domain.com/blog。 但是最好的办法是什么? 我应该将dnslogging的blog.domain.com更改为我的nginx服务器,然后让nginx处理重写/redirect? 或者我应该把重写在Apache服务器上? 我只能访问Apache服务器上的.htaccess文件。 我从来没有这样做过,所以我想问问社区什么是这样的情况下最好的办法。 谢谢

阿帕奇瓶颈

我有nginx作为前端代理和Apache与mod_fcgid。 这个盒子有24GB RAM和16个核心。 我不应该是瓶颈。 似乎有一个瓶颈。 一旦遇到7000个请求,它会在继续之前挂起。 编辑3:有人可以解释PHP_FCGI_CHILDREN ? 我把它设置为1,东西似乎更好地工作。 把它设置得更好吗? 它确实跨越了很多像疯子一样高的过程。 编辑:明智的错误日志: (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server 编辑 – 问题2因为我使用nginx作为前端代理。 是否有可能我所有的端口最大,因此不能再发送到后端(Apache)? 我也注意到PHP procs快速死亡 16409 USER 20 0 0 0 0 Z 27.2 0.0 0:00.82 [php] <defunct> 即使有这样的事情,它失败了: /usr/local/apache/bin/ab -n 1000000 -c 10 http://IP/index.php apr_poll: The timeout specified has expired […]

Nginx的多个服务器块

我有一个问题,试图configurationNginx与gitlab和我有一些其他网站的工作。 我有foo.com指向我的服务器。 bar.foo.com也指向我的服务器。 我想在bar.foo.com上有gitlab ,而在foo.com上有另一个网站 我想我可以很容易地做到这一点使用服务器块和server_names,但这似乎并不正确。 我试着做的是定义3个不同的服务器块,用不同的服务器名称。 但是这不起作用。 发生什么事是,当我尝试访问foo.com我结束了bar.foo.com这是gitlab。 不pipe我尝试做什么,我总是在gitlab上结束。 所以我想,也许根应该进入位置文件夹,但这似乎并没有改变任何东西。 在我的网站启用,我目前有3个文件:gitlab,website1和website2 任何帮助,将不胜感激。 这里是gitlabconfiguration文件 upstream gitlab { server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; } server { listen 80; # eg, listen 192.168.1.1:80; server_name bar.foo.com www.bar.foo.com; # eg, server_name source.example.com; #root /home/gitlab/gitlab/public; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { root /home/gitlab/gitlab/public; # […]

nginx反向代理不返回网站

设置 目前,我们有一个Apache2 web服务器充当我们web架构的负载平衡器。 后端是Xen虚拟机,可通过IPv6访问公共Internet,并通过IPv4访问我们的VPN。 问题是Apache 2负载均衡器的性能不如我们想要的那样,所以我们切换到nginx。 configuration 安装的nginx版本是1.3.10,它是用标准的Debian选项编译的。 我们必须去这个版本,因为它是唯一支持这些虚拟机需求的IPv6后端。 目前,nginx只有一个“虚拟主机”或服务器块,它是以下内容。 upstream backend-cookissime-prod { server cookissime-prod.cookissime1.vm.cob:80 max_fails=5; server cookissime-prod.cookissime2.vm.cob:80 max_fails=5; } server { listen 37.59.6.220:80; # listen [::]:80; server_name www.cookissime.fr; access_log /var/log/nginx/cookissime-prod.log; error_log /var/log/nginx/cookissime-prod.log; ## send request back to apache1 ## location / { proxy_pass http://backend-cookissime-prod; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; […]

nginx – 隐藏.php扩展名,并将* .php请求永久redirect到干净的url

经过大量的search,我已经设法得到漂亮的URL使用: server { listen 80; server_name www.url.com; rewrite ^/(.*) http://url.com/$1 permanent; } server { listen 80; server_name url.com; access_log /var/www/url.com/logs/access.log; error_log /var/www/url.com/logs/error.log; location / { root /var/www/url.com/public/; index index.html index.htm index.php; include /etc/nginx/mime.types; try_files $uri $uri/ @extensionless-php; } location @extensionless-php { rewrite ^(.*)$ $1.php last; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index […]

识别高端VPS(Apache 2.4 event_mpm / lighttpd / nginx)的性能瓶颈

我有一个来自vpsblast(他们的SSD13)的高端VPS – 在1GigE互联网主干上的4个核心,16GB RAM,320GB固态硬盘空间(几乎没有争议)。 就在我可以告诉它正在运行OpenVZ(使用simfs,user_beancounters存在)。 数据库在同一个数据中心的不同节点上,而且我正在运行php-fpm,但是这个testing涉及到一个静态的9.49kb图像(因为php-fpm在飞行,应用程序非常优化)。 所有请求都通过https,所以我运行了http和httpstesting来确定SSL是否是问题,但我不相信这是问题。 操作系统是Ubuntu 12.04 LTS。 我已经testing了apache 2.4(使用event_mpm),nginx和lighttpd,而且我看到了三个类似的performance,这导致我相信这不是httpd问题。 我目前使用Apache 2.4来解决这些问题。 我在静态物体上的performance达到峰值约400rps(请求每秒)。 这就像3.7Mbps,在1GigE线的限制下。 所以第一个问题:在这种设置上我应该看到什么性能? 在FreeNode的#apache讨论中,有人build议10k并发不应该是不可能的,我应该能够每秒处理10k个请求。 这些期望是不合理的吗? 下一个问题是确定性能瓶颈。 我真的不知道从哪里开始看,因为一切看起来都很好(我已经包含了从下面的截图)。 我没有做任何sysctl调整,因为他们似乎主要是由主机操作系统控制。 我在/etc/security/limits.conf中增加了软硬限制: www-data hard nofile 1048576 www-data soft nofile 1048576 root hard nofile 1048576 root soft nofile 1048576 我的apache httpd.conf是2.4的相当标准,但这里是我所做的更改: DocumentRoot "/var/www" <Directory "/var/www"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> <IfModule […]

大的javascript文件没有被nginx正确的服务

我遇到麻烦通过SSL启用gzip通过ssl服务大(376kb)JavaScript文件。 该文件服务没有问题在普通的旧的http。 有问题的文件是ckeditor.js,位于https://www.myleadconverter.com/js/lib/ckeditor/ckeditor.js 我search了周围,我发现了所有关于gzip_buffers的信息。 我发现的一切似乎都链接回http://blog.leetsoft.com/2007/07/25/nginx-gzip-ssl.html 来自我的nginx.conf的相关位: gzip on; gzip_comp_level 5; gzip_proxied any; gzip_buffers 16 8k; gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; gzip_vary on; 目前,下载停止在105kb,但应该是119kb压缩(这个信息是从铬开发工具)。 如果我使用wget并提供accept-encoding头文件,它将最终加载,但是只有在几次重新开始下载之后: mac2:Desktop andrewmullins$ wget -S –header="accept-encoding: gzip" https://www.myleadconverter.com/js/lib/ckeditor/ckeditor.js –2013-02-26 00:30:04– https://www.myleadconverter.com/js/lib/ckeditor/ckeditor.js Resolving www.myleadconverter.com… 184.106.67.181 Connecting to www.myleadconverter.com|184.106.67.181|:443… connected. HTTP request sent, awaiting response… HTTP/1.1 200 OK […]

Zend 1与Ubuntu的MSSQL不工作

有谁知道如何解决以下问题? 如果没有,有没有人知道如何在Linux上设置Zend 1与MSSQL服务器通信? 尝试使用freetds和pdo_dblib适配器时,我们在nginx日志中得到以下错误。 我们使用nginx 1.2.7在Ubuntu 12.04上运行Zend 1.2 2013/02/27 20:48:24 [error] 9057#0: *28 FastCGI sent in stderr: "PHP message: PHP Warning: include_once(Zend/Db/Adapter/Pdo/Dblib.php): failed to open stream: No such file or directory in /www/development/library/Zend/Loader.php on line 146 PHP message: PHP Warning: include_once(): Failed opening 'Zend/Db/Adapter/Pdo/Dblib.php' for inclusion (include_path='/www/development/application/../library:/www/development/library:.:/usr/share/php:/usr/share/pear') in /www/development/library/Zend/Loader.php on line 146 PHP message: PHP […]

nginx,gitlab,子域

我已经在虚拟机中的一个Ubuntu(12.04)虚拟机上安装了gitlab,在我的NAS上(在Windows 7上) 这台机器的主机名是vubuntu。 我的路由器(番茄v1.28)被configuration为使用.lan域名。 在我的工作站上,我可以使用地址vubuntu.lan成功ping通虚拟机 nginx中gitlab的configuration文件与安装文档中给出的一样,除了我更改了listen和server_name参数: # Maintainer: @randx # App Version: 4.0 upstream gitlab { server unix:/home/gitlab/gitlab/tmp/sockets/gitlab.socket; } server { listen 192.168.0.5:80; # eg, listen 192.168.1.1:80; server_name gitlab.vubuntu; # eg, server_name source.example.com; root /home/gitlab/gitlab/public; # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; location / { # serve static files from […]

改变nginx的端口

我想在同一台机器上运行apache和nginx。 我configuration了Apache,并在端口80上运行正常。现在我想在端口7007上configurationnginx。我在nginx.conf中做了更改。 这里是nginx.conf文件 – user nginx root; worker_processes 3; worker_rlimit_nofile 200000; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 65535; use epoll; } http { include /etc/nginx/mime.types; default_type application/octet-stream; index index.php index.htm index.html; 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; […]