我注意到以下行为或PHP-FPM: 看看这两个Nginx的configuration: server { listen 80; server_name example.com; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /srv/www/i.php; fastcgi_param PHP_VALUE "display_errors=1"; include fastcgi_params; } } server { listen 80; server_name example.net; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /srv/www/i.php; include fastcgi_params; } } 和/srv/www/i.php文件: <?php phpinfo(); 正如你可以看到唯一的区别是fastcgi_param PHP_VALUE "display_errors=1"; 。 现在,如果您杀死所有FPM工作者,并首先打开example.net ,您将会看到display_errors Off 。 在example.com你会看到display_errors为On 。 但是如果你再次访问example.net […]
我意识到这看起来像至less有其他几个问题的重复,但我已经多次阅读它们,但仍然做错了什么。 以下是位于/etc/nginx/sites-available myexample.com nginxconfiguration文件的内容。 server { listen 443 ssl; listen [::]:443 ssl; server_name myexample.com www.myexample.com; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; ssl_certificate /etc/letsencrypt/live/myexample.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/myexample.com/privkey.pem; #Configures the publicly served root directory #Configures the index file to be served root /var/www/myexample.com; index index.html index.htm; } 它的工作原理,当我去https://myexample.com内容服务和连接是安全的。 所以这个configuration似乎是好的。 现在,如果我将ssl端口更改为9443并重新加载nginxconfiguration,则configuration将无误地重新加载,但访问https://myexample.com会在浏览器中显示错误(无法到达此站点/ myexample.com拒绝连接。ERR_CONNECTION_REFUSED) 我已经尝试了build议和文档, 在 这里 , 在 这里 (其中),但我总是得到ERR_CONNECTION_REFUSED错误。 我应该注意到,我可以使用非标准端口,然后将该端口显式input到URL中,例如https://myexample.com:9443 。 […]
我有NginX使用fcgi为drupal站点提供服务。 试图浏览到一个不存在的PHP文件(例如www.example.com/this-file-doesn't-exist.php)会导致出现此错误的白屏: '没有指定input文件' 我用这个post来帮我设置NginX: http : //drupal.org/node/110224 这是我的NginXconfiguration文件: server { listen 1.2.3.4:80 default; server_name www.example.com; client_max_body_size 6M; root /var/www/example.com/; index index.php; error_page 404 /index.php; error_page 403 /403.html; # set up a location to serve static images for static error pages location ^~ /error_images/ { root /var/www/static_pages/error_pages; access_log off; expires 30d; } # use our own […]
好的:我已经build立了一个站点,其中有一些我们向开发人员公开的API,它们是这种格式的 /api/item.xml?type_ids=34,35,37®ion_ids=1000002,1000003&key=SOMERANDOMALPHANUM 在这个URI中,type_ids总是被设置的,region_ids和key是可选的。 重要的是要注意的是,关键variables不影响响应的内容。 它用于对请求进行内部跟踪,以便我们可以识别出请求缓慢或不需要的人员。 在Varnish中,我们有这样一个VCL: if (req.http.host ~ "the-site-in-question.com") { if (req.url ~ "^/api/.+\.xml") { unset req.http.cookie; } } 我们只是删除cookie,让后端完成剩下的工作(这是Rails / authlogic用API响应发送会话cookie的方法)。 目前,任何不同的开发人员基本上都会碰到不同的caching,因为&key=SOMEALPHANUM被认为是用于存储的Varnish散列的一部分。 这显然不是一个很好的解决scheme,我正在努力解决如何告诉Varnish忽略URI的那部分。
在NGinx持有的TCP连接上,可以configuration发送TCP Keepalive ( 不是 HTTP KeepAlive!)
我在nginx中使用image_filterresize来调整Amazon S3中的一组图像。 我想能够保存resize的图像,以便第二次和以后的图像请求不需要resize。 我已经制定了如何在Nginx中caching原始图像,所以至less从S3不是连续检索图像,但我不能解决如何caching在nginx服务器上resize的图像。 这可能吗? 这里是我的nginxconfiguration的相关部分(所有这个服务器都是调整图像大小): location / { try_files $uri @resizer; # directive to tell it to first look locally, then look @resizer root /var/www/nginx-default/images/; image_filter resize 400 300; image_filter_buffer 2048M; image_filter_jpeg_quality 75; image_filter_transparency off; error_page 415 = /empty; } location @resizer { proxy_pass http://my-s3-bucket; proxy_store on; proxy_temp_path /var/www/nginx-default/cache$uri; proxy_store_access user:rw group:rw all:r; image_filter […]
我正在用fastcgi在nginx上运行django。 当我做runfcgi时,我看到这些错误: python manage.py runfcgi daemonize=false host=127.0.0.1 port=8000 WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! 在我的nginx错误日志中,我看到这个: 2011/01/31 10:33:16 [error] 15921#0: *4 FastCGI sent in stderr: "WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT […]
我试图通过不为每个我testing的新站点创build一个新的nginx服务器configuration来节省一些时间在我的开发机器上。 我想知道是否有一种方法让nginx根据我加载的域来更改根目录。 所以,如果我有 mysite.loc myothersite.loc something.loc Nginx会看里面 www/mysite.loc www/myothersite.loc www/something.loc 这将允许我在模拟域上testing新事物的速度稍微快一点,因为我不必为每个域configuration新的/ etc / nginx / sites-availableconfiguration。 server { listen 80; server_name *.loc; root /www/$host; index index.html; } 这可能吗? 还有另一种方法吗?
我build立一个环境(在Ubuntu 10.04.02机器上)处理一个网站与许多(应该至less支持1000)子域,其中每个子域,由不同的FPM池,与不同的用户。 没有什么新鲜的 我的问题是创build(和启动)一个新的FPM池,而不必重新加载/重新启动FPM,这将导致(我知道,非常快)的停机时间。 我写了一个python守护进程,当需要的时候: 创build系统用户 设置子域的Web根目录 创buildsubdomain.conf到我的/etc/php5/fpm/fpm.d/文件夹中 我search了一下,但我没有find一种方法来调用fpm使用一个池,这可能是一个'临时'的解决scheme:主要的fpm实例运行所有的池,evey新的获得自己的fpm实例,然后用cron停止,每周/每月/ dontknowyet重新加载fpm 如果没关系,服务器运行在nginx上,configuration为使用unix socket到fcgi,这是我的nginxtestingconfiguration: server{ listen 80; server_name ~^(?<domain>.+)\.test\.local$; # foo.test.local > myapp_foo root /var/www/myapp/subdomains/myapp_$domain/htdocs; location / { index index.php; } location ~* \.(gif|jpg|png|ico)$ { expires 30d; } location ~ \.php$ { fastcgi_pass unix:/var/web-sock/myapp_$domain-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } ..和我的子域 – fpm.conf: [myapp_foo] listen = […]
我有一些网站共享一个IP地址的情况。 我有nginx接受请求并将它们传递给实际为这些站点提供服务的Apache。 我知道Apache并不是真的需要在这里,但是由于历史的原因,Apache是这样设置的,如果我不需要的话,我宁愿不改变它。 nginx接受对example.com的请求并将其传递给Apache,如下所示: server { listen 80; server_name example.com www.example.com; access_log /var/log/nginx/example.log; error_log /var/log/nginx/example.log; location / { proxy_read_timeout 120; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:8100; } } 在httpd.conf中,我们有 <VirtualHost localhost:8100> ServerName www.example.com ServerAlias example.com Options Indexes DocumentRoot /export/sites/example/live ServerAdmin [email protected] </VirtualHost> 一切都工作得很好,但我已经添加了一个PHP脚本(不是我自己的)到网站,它不能得到正确的主机名。 $ _SERVER [“HTTP_HOST”]和/或$ _SERVER ['SERVER_NAME']返回localhost:8100而不是example.com。 是否有可能设置这样的PHP将获得正确的主机名?