Articles of nginx

nginx – linux权限有趣的问题

我想得到一些答案或build议,以我的问题。 所以我得到一个简单的错误: 2014/02/16 12:01:43 [error] 7384#0:* 1在读取来自上游的响应头时,stderr中发送的“主脚本未知”,客户端:127.0.0.1,server:localhost,request:“GET / HTTP / 1.1“,上游:”fastcgi:// unix:/var/run/php-fpm.sock:“,主机:”localhost“ 首先,我的nginxconfiguration做得很好(对我来说 – 也就是说它运行良好)。 我唯一的问题是与Linux文件/文件夹的权限。 我无法理解我所处的情况。好的,这里是一些需要的信息: 我的nginx运行良好,configuration了PHP和mysql。 一个用于nginx的用户被命名为“ nginx ” index index.php index.html index.htm (index指令的nginxconfiguration) 这是我的问题: 我有一个树,如: / home / user / 主目录是: 根: 755 根 用户目录是: 用户:用户 700 我在/home/user/index.php中创build了一个名为index.php的文件 。 Nginx说(/var/log/nginx/error.log)我没有权限。 好的,我做了“ usermod -a nginx -G用户 ”,并将“ user ”目录的权限更改为: 750 (所以现在nginx属于用户组,并且可以读取或执行用户目录的内容)。 好吧,这有效,但不是100%的方式。 如果我现在创build一个文件index.html […]

nginx / php-fpm“主要脚本未知”从一个复杂的path服务时

我有一个web应用程序(simpleSAML.php)包装在一个Wordpress小部件,需要服务path如下: http://example.com/wp-content/plugins/saml-20-single-sign-on/saml/www/module.php/saml/sp/metadata.php/1 我的WordPress的nginxconfiguration工作正常,但需要服务上面的复杂path的部分没有。 它返回“文件未find”,并在nginx日志中发布“主脚本未知”错误。 这是我在vhostconfiguration中的: server { listen 80 default; server_name *.example.com example.com; root /srv/web/wpmulti; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/example.error.log; index index.html; location / { index index.html index.htm index.php; include global/restrictions.conf; include global/wordpress-ms-subdir.conf; rewrite ^ http://example.com$request_uri permanent; } location /wp-content/plugins/saml-20-single-sign-on/saml { alias /srv/web/wpmulti/wp-content/plugins/saml-20-single-sign-on/saml/www; location ~* /saml/(?<script>.+?\.php.*)(?<pathinfo>.*)?$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_NAME /saml/$script; […]

当斜线结束时,nginx路由失败

以下nginxconfiguration服务http://alpha.mydomain/mypath/test罚款,但在http://alpha.mydomain/mypath/test/与500内部服务器错误失败。 注意第二个URL末尾的斜杠。 该应用程序是HTML5应用程序,因此意图是为所有/ mypath /path提供index.html,并让客户端处理逻辑。 server { listen *:80; server_name alpha.mydomain.com beta.mydomain.com; location ~ ^/mypath/.*$ { default_type text/html; # fix for octet stream coming back sometimes alias /home/ubuntu/myproject-web/index.html; add_header Content-Type text/html; } location / { alias /home/ubuntu/myproject-web/; } }

第一次访问nginx&php-fpm非常慢

我有一个nginx 1.4.5 web服务器与运行在我的服务器上的php-fpm 5.5.7,但如果我的服务器保持闲置一段时间,访问它是非常缓慢的。 得到响应(第一个字节)需要大约10-20秒,之后再快速。 我不知道为什么需要一段时间后回访第一次访问。 我试了两个unix套接字和tcp,没有效果。 inheritance人我的configuration: NGINX: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1000; multi_accept on; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; sendfile on; keepalive_timeout 65s; keepalive_requests 1000; gzip […]

使用autoindex在Windows上的webserver上对文件名进行字符编码

我已经在Windows 8.1上build立了一个networking服务器。 现在我遇到了链接字符编码的问题:有包含德语变音符号的目录和文件名(äöüß)。 networking服务器的自动索引function为显示元音变音的目录生成索引页面,但用链接中的代理replace变音符:ü – >%fc和ö – >%f6。 结果,找不到链接的文件。 也不是发现,如果我手动键入ü而不是%fc 任何build议? networking服务器:nginx 1.5.10 nginx.conf中的字符集代码:charset iso-8859-1; 操作系统:Windows 8.1(服务器和客户端相同的框) 浏览器:铬和ie

MIME键入nginx的dynamicurl

用户上传文件并将其保存在file目录中,不带文件扩展名 所以它看起来像文件/ ID 我做了什么,当用户下载任何文件,我们已经创build了一个相同的重写规则,看起来像 重写^ / file /(.+?)/(.*)$ / file / $ 1; http://example.com/file/id/name.mp4 – > http://example.com/file/id 现在,我面对的问题是nginx给内容types(MIME)一个application/octet-stream 这不是实际的MIMEtypes的文件,这是因为默认的MIMEtypes是应用程序/八位字节stream 我也知道我们可以用nginxconfiguration改变一样的, 但我的问题是,我们可以设置MIMEtypes的基础上的URL文件扩展名

优化nginx站点configuration

第一次使用nginx。 由于我对location指令优先级的知识有限,我不得不在两个地方(fastcgi)重复代码。 我可以优化这个文件,而不是重复代码? 这是我的服务器文件。 server{ server_name www.theme-dev.local; return 301 $scheme://theme-dev.local$request_uri; } server { listen 80; root /var/www; error_log /var/log/nginx/theme-dev.local/server.log warn; index index.php index.html; server_name theme-dev.local; chunked_transfer_encoding off; proxy_buffering off; location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } location ~ /\.ht { access_log off; deny all; […]

当我尝试使用nginxcaching时,我获得了404资源

我search了一下,发现了一些关于如何在nginx上caching静态资源的脚本,问题是当我应用这些脚本的时候,我在脚本和样式上得到了404。 我在这里做错了什么? 我很抱歉,但我不知道如何从nano使用腻子复制,所以我做了我的configuration看起来像。 请注意,我评论caching部分。 如果我取消注释,我的静态文件将是404。

NGINX是否允许在不丢失请求的情况下将负载切换到另一台服务器?

NGINX是否允许从一台服务器切换到另一台服务器而不丢失请求? 我有一个SOAP API,NGINX将请求转发到三个服务器之一,每个服务器将其转发到队列,然后等待来自队列的响应,然后客户端等待来自API的响应。 如果客户端没有得到响应,请求仍然通过,只有客户端不知道他执行的操作成功完成。 因此,如果我需要升级其中一个SOAP前端,我需要将负载切换到其他两个前端之一,但是不会丢弃任何现有的连接,这对NGINX来说是可能的吗?

从nginx连接到gunicorn_django时,连接被拒绝

我试图让升级后的服务器恢复在线状态,我不能再让Nginx直接调用Gunicorn了 – 我发送给网站的每个请求都会返回一个502 Bad Gateway 。 我在端口8001上运行gunicorn_django (从ps aux | grep gunicorn可以看到 – 两个worker的命令的参数是-b 0.0.0.0:8001 。我的Nginxconfiguration在我的唯一configurationsites-enabled : upstream django_test { server 127.0.0.1:8001; } …所以它应该是要求那里。 自升级以来,这个configuration文件没有任何改变。 当我在浏览器中访问mysite.com/robots.txt时,会返回我在sites-enabled了sites-enabledconfiguration中定义的robots.txt ,因此文件肯定会被加载。 此外,当我从服务器运行curl 127.0.0.1我仍然得到502 bad gateway 。 有谁知道这里会发生什么?