我使用的是Nginx 0.7.64,Passenger 2.2.9,Rails 2.3.5。 我有我的页面caching目录设置为/公共/caching,我希望能够提供caching页面时,通过HTTP请求,但总是击中Rails应用程序通过HTTPS请求时。 我的configuration大部分是这样的: server { listen 80; server_name website.com www.website.com; proxy_set_header X-Forwarded-Proto http; root /home/deploy/website/current/public; passenger_enabled on; if (-f $document_root/cache/$request_filename.html) { rewrite (.*) $document_root/cache/$1.html break; } } server { listen 443; server_name website.com www.website.com; root /home/deploy/website/current/public; passenger_enabled on; proxy_set_header X-Forwarded-Proto https; ssl on; ssl_certificate /home/deploy/website/shared/ssl/www.website.com.combined.crt; ssl_certificate_key /home/deploy/website/shared/ssl/www.website.com.key; } 我预计,当我请求website.com/about时,我应该被提供/public/cache/about.html,但是我打了Rails服务器(拖尾日志显示它)。 思考我可能有一个不恰当的斜线(在大多数例子中没有看到$document_root ),我也尝试了以下所有的变化,没有一个工作: if […]
我运行Nginx并通过FastCGI代理PHP请求到PHP-FPM进行处理。 我将随机收到502错误的网关错误页面 – 我可以通过点击我的PHP网站非常迅速/刷新页面一两分钟来重现此问题。 当我得到502错误页面时,我所要做的就是刷新浏览器并正确刷新页面。 这是我的设置: nginx / 0.7.64 PHP 5.3.2(fpm-fcgi)(内置:Apr 1 2010 06:42:04)Ubuntu 9.10(最新的2.6 Paravirt) 我使用这个./configure指令编译PHP-FPM ./configure –enable -fpm –sysconfdir = / etc / php5 / conf.d –with-config-file-path = / etc / php5 / conf.d / php.ini –with-zlib –with -openssl –enable-zip –enable-exif –enable-ftp –enable-mbstring –enable-mbregex –enable-soap –enable-sockets –disable-cgi –with-curl –with -curlwrappers –with-gd –with-mcrypt –enable-memcache […]
我正在将我的项目的web堆栈重构为:nginx – > haproxy – >许多(apache / passenger rails)实例 其中一些目标包括: 页面caching的单个位置(目前通过每个Apache机器上的轨道完成) 更快的静态内容 从内部pipe道中删除ssl ip日志logging(以前由于在tcp模式下运行haproxy而丢失) image / stylesheet / javascript资源被高速caching,并具有适当的头文件。 我们的页面caching是基于内部参数的,不应该对典型的caching控件做出响应。 为了达到这些目的,我们的configuration看起来像这样 server { … location /really_slow_dynamic_content/ { root /var/www/tmp; error_page 404 = @fetch; } location @fetch { internal; proxy_pass haproxy_ip; proxy_store /var/www/tmp${uri}_cache.html; proxy_store_access user:rw group:rw all:r; } location /assets/ { proxy_pass haproxy_ip; proxy_cache assets; } […]
我们使用Nginx作为使用HTTP Auth的Apache服务器的反向代理。 出于某种原因,我无法将HTTP_AUTHORIZATION头信息传递给Apache,它似乎被Nginx过滤掉了。 因此,没有请求可以authentication。 请注意,基本身份validation是dynamic的,所以我不想在我的nginxconfiguration中对它进行硬编码。 我的nginxconfiguration是: server { listen 80; server_name example.co.uk ; access_log /var/log/nginx/access.cdk-dev.tangentlabs.co.uk.log; gzip on; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_read_timeout 120; location / { proxy_pass http://localhost:81/; } location ~* \.(jpg|png|gif|jpeg|js|css|mp3|wav|swf|mov|doc|xls|ppt|docx|pptx|xlsx|swf)$ { if (!-f $request_filename) { break; proxy_pass http://localhost:81; } root /var/www/example; } } 任何人都知道这是为什么发生? 更新 – 事实certificate,这个问题是我原来的问题,我忽略了:mod_wsgi。 这里所讨论的网站是一个Django站点,事实certificate,Apache确实得到了通过的authvariables,但是mod_wsgi将它们过滤掉了。 […]
为什么http://compassionpit.com/blog/会经历无限的redirect循环? 这是我的nginx conf文件。 该站点由端口8000上的nodejs服务器运行,Apache提供博客(wordpress)和论坛(phpBB)。 该论坛正在解决就好了,在http://www.compassionpit.com/forum/ … server { listen 80; server_name www.compassionpit.org; rewrite ^/(.*) http://www.compassionpit.com/$1 permanent; } server { listen 80; # your server's public IP address server_name www.compassionpit.com; index index.php index.html; location ~ ^/$ { proxy_pass http://127.0.0.1:8000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location @blogphp { internal; root /opt/blog/; include […]
我试图得到一个LNP [Linux的Nginx Python]堆栈(这是甚至是一个东西?嘿),但我有一些困难。 很多博客文章和文档似乎都围绕使用Upstart来pipe理uWSGI进程,这很好,但是我注意到在/etc/uwsgi/{apps-enabled,apps-available} uwsgi中安装了init.d脚本和一些configuration目录的软件包/etc/uwsgi/{apps-enabled,apps-available} 。 所以显然有一个更好的方法来做到这一点。 我有一些configuration文件(下面),但我似乎无法启动uwsgi进程,运行init.d脚本什么也不做,报告成功,但失败(甚至没有日志)。 当我直接执行uWSGI我得到这个: % sudo uwsgi -i /etc/uwsgi/apps-enabled/site.ini tmp = / [uWSGI] getting INI configuration from /etc/uwsgi/apps-enabled/site.ini /usr/lib/uwsgi/plugins/python27_plugin.so 另外值得注意的是,当我尝试访问该网站时抛出的错误: % cat logs/error.log 2012/01/08 23:26:12 [crit] 9167#0: *13 connect() to unix://tmp/site.sock failed (2: No such file or directory) while connecting to upstream, client: 60.241.99.33, server: mysite.com, request: "GET / HTTP/1.1", […]
我有一个configuration文件,如下所示: /var/log/nginx/*.log { daily missingok rotate 90 dateext compress notifempty create 644 root adm sharedscripts postrotate [ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid` /usr/local/bin/synclogs.sh endscript } 当所有的日志文件被旋转和压缩时,synclogs.sh应该运行。 脚本确实启动成功,但是当它开始运行时,程序没有find任何logrotate应该创build的.gz文件。 几分钟后我手动运行脚本,它踢得很好。 根据我发现的文档,postrotate不应该启动,直到压缩完成。 情况不是这样吗? 这是一个在Debian挤压发布的logrotate中的错误,还是我错过了一些非常简单的东西?
显然Nginx现在支持分块,但是当平板设备向Nginx发送分块请求时,我收到“411 Length Required”错误。 任何有关如何configurationNginx支持分块的build议? 我正在使用v.1.3.9。 我知道有一个类似的问题被问到 ,但是在2010年之前,Nginx支持chunked。 我的nginx.conf: master_process off; worker_processes 1; daemon off; pid /usr/nginx/logs/nginx.pid; events { worker_connections 1024; } http { ngao_filters_directory /usr/nginx/filters; include mime.types; default_type application/octet-stream; # prevent caching by client add_header Cache-Control "no-store, no-cache"; sendfile on; keepalive_timeout 65; server { listen 8081; server_name localhost; client_max_body_size 3m; chunked_transfer_encoding on; scgi_temp_path /usr/nginx/scgi_temp; uwsgi_temp_path […]
双重上传 自从我们从一个简单的Apache实例转到一个负载均衡的环境之后,有时POST请求会重复出现问题。 我们运行nginx作为反向代理。 静态内容由nginx自身提供,dynamic内容由两个Apache后端提供。 我检查了它不是一个接口/用户错误。 一个小例子:一个简单的图片上传将导致图片上传两次。 请求/ POST不会通过双击或用户失败发送两次。 我还没有find任何证据表明浏览器发送请求两次,所以我怀疑是在服务器端。 (请注意,这只是怀疑。)这些请求中的大多数是内部的,这意味着它们来自员工,所以我可以validation它们是如何发生的。 我唯一能find的错误是nginx会在这些情况下logging一个499错误。 但是,我不确定这是问题的原因还是(侧面)影响。 (我知道499不是默认的http状态,这是一个nginx状态,意思是“客户端已经closures了连接”) 要求 重复的POST请求几乎是所有可能需要一段时间的请求。 我在这里展示的一个例子是一个简单的图片上传,但脚本在后台做了一些东西(图片必须被转换成不同的格式/大小,并且应该分发到两个服务器等)。 日志 一个例子是上传图片。 nginx会logging一个'499'和一个200请求,但是Apache正在接收(和处理!)两个请求。 阿帕奇 [17:17:37 +0200] "POST ***URL** HTTP/1. 0" 200 9045 [17:17:47 +0200] "POST ***URL** HTTP/1. 0" 200 20687 nginx的 [17:17:47 +0200] "POST ***URL** HTTP/1.1" 499 0 [17:17:52 +0200] "POST ***URL** HTTP/1.1" 200 5641 猜疑 在我看来,更大/更慢的上传遭受这个更多,所以我怀疑超时。 我试图读到499错误:结论似乎是“客户端closures”。 在后台可能会出现这种情况,但我不确定这是否意味着应该发出第二个请求,并且确实没有像“用户closures的浏览器”这样的事情发生。 […]
我正在寻找这个问题的解决scheme。 我理解为什么在这个问题的设置不起作用的原因,但我试图find一个解决scheme,我可以得到它的工作。 这个想法是只允许在某些URL上进行大file upload。 我可以使用这个location块,但问题是:我有一个PHP的前端控制器模式: location ~ \.php { # … fastcgi_pass unix:/tmp/php5-fpm.sock; } 我的总configuration看起来像: # … http { # … client_max_body_size 512K; server { server_name example.com; root /var/www/example.com/public; location / { try_files $uri /index.php?$query_string; } location /admin/upload { client_max_body_size 256M; } location ~ \.php { # … fastcgi_pass unix:/tmp/php5-fpm.sock; } } } 据我所知,只有一个位置块将被应用。 所以如果我有512K的默认请求大小,256M永远不会被应用,因为所有的请求都通过前台控制器模式~ […]