Articles of nginx

PHP头redirect工作在nginx甚至输出发送

注意:有一个类似的问题,但这是关于Apache。 下面的代码 <?php echo '.'; header('Location: http://stackoverflow.com'); 完全“工作”在Nginx 0.7.67下,其中“工作”意味着PHP的redirect工作正常,没有在错误日志中的错误或显示. 。 我如何强制nginx或php-fpm抛出PHP Warning: Cannot modify header information – headers already sent by警告PHP Warning: Cannot modify header information – headers already sent by ?

Perl不能通过fastcgi与Nginx合作,无法破译错误日志

我运行CentOS 6.2 , Nginx 1.2.3遵循这些Linode指令让Perl与Nginx一起工作我已经做了所有的事情来testing一个实际的Perl文件。 当我这样做浏览器说: The page you are looking for is temporarily unavailable. Please try again later. 而我的Nginx error-log显示如下: 2012/09/02 22:09:58 [error] 20772#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.102, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "192.168.1.10:81" 我坚持在这一点上。 林不知道是否重要,但我也有spawn-fcgi和php-fpm来提供这个网站上的PHP文件,但这应该是从perl-fastcgi设置,不同的端口等100%分开。 我怎样才能解决这个问题?

NGINXredirect子域名到子目录

我知道这肯定已经被回答了一百万次,但是我似乎无法得到它的工作 我想将一个子域redirect到一个子目录。 我目前正在使用 server { server_name sub.domain.com; rewrite ^(.*) http://www.domain.com/sub-directory permanent; } 如果我导航到sub.domain.com我redirect到http://www.domain.com 编辑 这是我的完整configuration。 我已经改变了实际的域和子目录 server { server_name forum.domain.com; rewrite ^(.*) http://www.domain.com/forum permanent; } server { # Listen on port 80 as well as post 443 for SSL connections. listen xx.xxx.xxx.xxx:80; server_name domain.com www.domain.com; # Path to the files in which you wish to […]

在nginx中分块响应不起作用

我碰到这个post,这显示我的问题是确切的 http://nginx.org/en/docs/faq/chunked_encoding_from_backend.html 但浏览器现在使用http 1.1,所以我真的不明白。 我们的后端是playframework,我不介意修复它,但我不明白什么是不工作特别是因为Firefox,Safari浏览器,铬ALL下载响应就好,没有问题。 只有当我们坚持把NGINX放在中间的时候,事情就会破裂,我们在json响应中会得到额外的数据。 任何想法如何解决这个问题? 正如上面的文件似乎是错误的,因为我们现在在更高版本的http加上浏览器似乎工作得很好。 谢谢,Dean

使用nginx执行php脚本的麻烦

我的nginxconfiguration看起来像这样 server { listen 80; server_name localhost; location / { root /var/www; index index.php index.html; autoindex on; } location /folder1 { root /var/www/folder1; index index.php index.html index.htm; try_files $uri $uri/ index.php?$query_string; } location /folder2 { root /var/www/folder2; index index.php index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; […]

PHP的页面生成时间为0.01s。 1 / 0.01 = 100; 但是,我遇到了每秒钟的请求数量的问题。 为什么?

平均而言,我的PHP页面生成时间是10ms。 所以我应该能够一个接一个地执行100个请求(使用服务器上的一个核心,因为这个PHP不是multithreading的)。 但是,我有问题达到每秒50页。 截至目前我平均25日,中等负载。 应用程序非常轻便,它包含从SSD池读取(<5KB),一些读取查询通过索引解决。 我应该在哪里解决这个瓶颈?

解释了nginxconfiguration文件

我在/ etc / nginx / sites-enabled中有一些关于这个configuration文件“default”的问题。 如下所示。 server { root /usr/share/nginx/www; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { proxy_pass http://127.0.0.1:8080; } location /doc { root /usr/share; autoindex on; allow 127.0.0.1; deny all; } location /images { root /usr/share; autoindex off; } } 没有“听”指令,它怎么知道默认为80 server_name是localhost,另一个域如何工作? 为什么位置指令embedded在服务器指令中? 这是否意味着这些位置只适用于此服务器? 我的configuration没有听80 default_server; […]

为什么nginx重写从/login/ /login发布请求?

有一个if语句,当客户端是Android的时候会重写url。 一切还好。 但是,有些奇怪的东西。 即使if语句的块是bank,Nginx也会将post请求/login写入//login。 所以我有一个404页面。 由于docker服务器只接受/login请求。 服务器conf: location / { proxy_pass http://localhost:8785/; proxy_set_header Host $http_host; proxy_set_header Remote-Addr $http_remote_addr; proxy_set_header X-Real-IP $remote_addr; if ( $http_user_agent ~ Android ){ # rewrite something, been commented } } debugging信息,原始日志https://gist.github.com/3799021 … 2012/09/28 16:29:49 [debug] 26416#0: *1 http script regex: "Android" 2012/09/28 16:29:49 [notice] 26416#0: *1 "Android" matches "Android/1.0", client: 106.187.97.22, […]

用nginx把基址重写为https

我想只有我的基地域名www.domain.com被重写为https://www.domain.com默认情况下,我的https地址块我重新路由到http://如果不是〜uri =“/” (基本域)或静态内容。 server { listen 443; set $ssltoggle 2; if ($uri ~ ^/(img|js|css|static)/) { set $ssltoggle 1; } if ($uri = '/') { set $ssltoggle 1; } if ($ssltoggle != 1) { rewrite ^(.*)$ http://$server_name$1 permanent; } } 所以在我的http块我需要做重写,如果它有https: server { listen 80; if ($uri = '/') { set $ssltoggle 1; } if ($ssltoggle […]

用yum安装的nginx安装乘客

是否有可能将乘客安装到以前使用yum安装的nginx中? 我需要为install-nginx-module提供一个目录前缀,只是想知道Centos在哪里? passenger-install-nginx-module –auto-download –auto –prefix=$nginx_directory_prefix