标签: fastcgi

Nginx + fastcgi截断问题

我使用fastcgi接口运行一个Django站点到nginx.但是,某些页面正在被截断(即页面源只是停止,有时在标记的中间).我该如何解决这个问题(让我知道需要哪些额外信息,我会发布)

细节:

我正在使用flup,并使用以下命令生成fastcgi服务器:

python ./manage.py runfcgi umask=000 maxchildren=5 maxspare=1 minspare=0 method=prefork socket=/path/to/runfiles/django.sock pidfile=/path/to/runfiles/django.pid
Run Code Online (Sandbox Code Playgroud)

nginx配置如下:

# search and replace this: {project_location}
pid /path/to/runfiles/nginx.pid;
worker_processes  2;
error_log /path/to/runfiles/error_log;
events {
    worker_connections  1024;
    use epoll;
}
http {
    # default nginx location
    include        /etc/nginx/mime.types;
    default_type    application/octet-stream;
    log_format main
        '$remote_addr - $remote_user [$time_local] '
            '"$request" $status $bytes_sent '
        '"$http_referer" "$http_user_agent" '
        '"$gzip_ratio"';
    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;
    connection_pool_size        256;
    client_header_buffer_size    1k;
    large_client_header_buffers    4 2k;
    request_pool_size        4k;
    output_buffers   4 32k;
    postpone_output  1460;
    sendfile        on; …
Run Code Online (Sandbox Code Playgroud)

python django fastcgi nginx

10
推荐指数
3
解决办法
5466
查看次数

如何在Nginx上使用FastCGI运行Perl脚本?

所以我遵循这个指南:http://technotes.1000lines.net/?p = 23我正在完成这些步骤.我有一个使用Debian Etch的VPN(slicehost.com),用nginx为一个网站(静态到目前为止)提供服务.我使用wget下载FastCGI,我做了通常的make make install例程.

所以我想因为FastCGI无法正常运行CGI脚本,所以你必须使用某种类型的perl包装来解释perl.

现在我运行这个脚本

http://technotes.1000lines.net/fastcgi-wrapper.pl

我遇到了一个人在提交脚本的页面上遇到的完全相同的问题:

http://www.ruby-forum.com/topic/145858

(我不是一个红宝石人,那里没有任何红宝石定向)

我一直在接受

# bind/listen: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我不知道如何继续.我很感激任何帮助,我可以提供任何人需要的更多细节.

perl cgi fastcgi nginx

10
推荐指数
1
解决办法
1万
查看次数

nginx/apache/php vs nginx/php

我目前有一个服务器使用nginx,reverse_proxy到apache(相同的服务器)来处理php请求.我想知道我是否删除apache所以如果我看到任何性能提升,我会运行nginx/fastcgi到php.我假设我会因为Apache非常臃肿,但与此同时我不确定fastcgi/php是多么可靠,特别是在高流量情况下.

我的网站每个月可以获得大约200,000个独立访问者,每月有大约6,000,000次来自搜索引擎的页面抓取.这个数字正在稳步增加,所以我正在考虑执行选项.

我的网站是非常优化的代码,并且没有任何缓存(也不需要),每个页面最多有2个sql查询而没有任何其他表的连接,索引也是完美的.

在一年左右的时间里,我将重写所有内容以使用ClearSilver作为模板,然后可能使用python或c ++来获得极致性能.

我想我或多或少都在寻找任何熟悉nginx/fastcgi并且愿意提供一些基准的人的建议.我的网站是一个服务器,具有1个四核xeon,8gb ram,150gb velociraptor驱动器.

apache fastcgi nginx

10
推荐指数
1
解决办法
7980
查看次数

在C#应用程序中使用FastCGI应用程序

我正在用C#开发一个小型的Web服务器作为一个更大的项目的一部分(项目的性质阻止我使用像apache nginx这样的东西,这将是我的第一选择).

Web服务器需要PHP来处理它收到的一些请求.

目前我正在使用System.Diagnostics.Process运行php作为cgi,并将数据传输到管道.这工作但很慢(可能是从PHP开始从头开始的开销,是主要问题).所以我想尝试使用FastCGI.

我已经查看了FastCGI规范,并开始实现一个基本的子集,但没有太多运气.我见过的大多数示例都是用于开发FastCGI模块的库,而不是用于调用它们的库,所以我几乎没有用作参考.

有没有人在.NET下有这样做的经验,或者可以为这种项目推荐任何有用的资源?

php c# fastcgi

10
推荐指数
1
解决办法
1437
查看次数

我的nginx + fastcgi配置下载php文件而不是执行它们

我在ubuntu 13.04上全新安装php5-fpm和nginx时使用此配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
            try_files $uri $uri/ /index.html;
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            allow ::1;
            deny all;
    }

    error_page 404 /404.html;

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

            # With php5-cgi alone:
            fastcgi_pass 127.0.0.1:9000;
            # With php5-fpm:
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,我的Web浏览器将php视为文本而不是执行结果.我应该在哪里进行故障排除?

fastcgi nginx

10
推荐指数
1
解决办法
2万
查看次数

使用mod_headers与php-fpm/mod_fastcgi的问题

我正在尝试在我的应用中为每个响应添加HSTS标头.

我的第一个想法是使用mod_headers - 我将此指令放在documentroot的.htaccess文件中:

Header set Strict-Transport-Security "max-age=7776000"
Run Code Online (Sandbox Code Playgroud)

这在使用Apache 2.2和mod_php的本地设置上工作正常.所有资源都使用适当的HSTS标头进行响应.

我的部署环境使用Apache 2.2和mod_fastcgi,上述技术适用于 php文件之外的任何资源.

另一个SO 问题有一个类似的问题,传入的请求(?)有剥离标题 - 但我担心修改响应的标题离开服务器.

如何在.htaccess文件的上下文中向PHP资源添加响应头?

php apache .htaccess fastcgi

10
推荐指数
1
解决办法
1706
查看次数

file_get_contents('php:// input')返回带有PUT请求的空字符串

在将我们的一个网站从带有Apache的Linux移动到带有通过FastCGI运行PHP 5.6的IIS(8.5)的Windows之后,我们遇到了file_get_contents('php://input')为PUT请求返回空字符串的问题.

我创建了以下测试:

<?php
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
    strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    die(file_get_contents('php://input'));
}
?>
<!DOCTYPE html>
<html>
<head>
    <script src="//code.jquery.com/jquery-2.1.3.min.js"></script>
</head>
<body>
    <h2>POST:</h2>
    <div id="post"></div>

    <h2>PUT:</h2>
    <div id="put"></div>
    <script>
        $.ajax({
            url: '?',
            data: 'Working',
            type: 'POST'
        }).then(function(response) {
            $('#post').html(response || 'Not working');
        });

        $.ajax({
            url: '?',
            data: 'Working',
            type: 'PUT'
        }).then(function(response) {
            $('#put').html(response || 'Not working');
        });
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

结果如下:

POST:

工作

放:

不工作

可能是什么导致了这个?

php fastcgi iis-8.5

10
推荐指数
1
解决办法
1297
查看次数

什么是nginx中的fastcgi_index用于?

在许多网站上都可以找到这个nginx location块:

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000
    fastcgi_index index.php
    ...
}
Run Code Online (Sandbox Code Playgroud)

鉴于官方文档fastcgi_index,好像当请求,结束于使用/.但是,它与location上面的块的正则表达式不匹配?我错过了关于该fastcgi_index指令的一些内容吗?

fastcgi nginx

10
推荐指数
1
解决办法
8585
查看次数

使用PHP进行与环境无关的301/302重定向

偶然使用Status了FastCGI 的标题.在与环境无关的脚本中使用它有利有弊吗?

header('Location: ' . $url, true, 301);
Run Code Online (Sandbox Code Playgroud)

单独在Apache 2.2上没有问题(根据phpinfo(),服务器使用FastCGI).

该脚本针对Apache和nginx(mod_php和FastCGI).防故障解决方案会是什么样的?

php apache fastcgi nginx http-headers

10
推荐指数
1
解决办法
372
查看次数

FastCGI不使用Rails 4共享主机(Phusion Passenger)

我正在使用Rails 4.1.6和ruby 2.1.8p440.

目前,我想加快性能并添加配置FastCGI.

问题:FastCGI不起作用并且减慢了我的RoR APP.

到目前为止,我有这个目录结构:

  • 博客(Rails 4应用程序)
  • 的public_html
    • 的.htaccess
    • dispatch.fcgi

我的.htaccess文件:

PassengerAppRoot "/home/individualki/blogs"
PassengerBaseURI "/"
PassengerRuby "/home/individualki/rubyvenv/ror/2.1/bin/ruby"
RailsEnv development

SetEnv RAILS_RELATIVE_URL_ROOT /dispatch

RewriteEngine On

RewriteRule ^(stylesheets/.*)$ - [L]
RewriteRule ^(javascripts/.*)$ - [L]
RewriteRule ^(images/.*)$ - [L]

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ dispatch.fcgi [E=X-HTTP_AUTHORIZATION:%{HTTP:Authorization},QSA,L]
Run Code Online (Sandbox Code Playgroud)

我的dispatch.fcgi文件:

#!/home/individualki/rubyvenv/ror/2.1/bin/ruby



ENV['RAILS_ENV'] ||= 'development'  
ENV['HOME'] ||= `echo ~`.strip  
ENV['GEM_HOME'] = File.expand_path('~/.gems')  
ENV['GEM_PATH'] = File.expand_path('~/.gems') + ":" + '/usr/lib/ruby/gems/1.8'

require 'rubygems'  
Gem.clear_paths  
require 'fcgi'

require '../home/individualki/blogs/config/boot.rb'  
require …
Run Code Online (Sandbox Code Playgroud)

.htaccess fastcgi ruby-on-rails passenger ruby-on-rails-4

10
推荐指数
1
解决办法
133
查看次数