Articles of nginx

nginx uwsgi烧瓶重写目录作为基地目录内的应用程序

所以我有一个应用程序运行在Nginx上使用uWSGI。 Nginx设置为在位置/应用程序中调用我的应用程序。 所以在我的烧瓶应用程序中,当我将url映射到一个函数时,我必须考虑/ app部分。 有没有办法重写nginx文件或uwsgi config.xml文件让应用程序认为它是从/目录运行? 有没有副作用? 举个例子: 页面http://mysite.com/app/链接到我的index.py模块 我的index.py模块使用Flask,所以路由映射如下所示: @app.route('/app/') def hello_world(): return 'Hello World!' 我想知道如果我可以改变configuration文件,所以我可以写: @app.route('/') def hello_world(): return 'Hello World!' 代替?

Nginx重写规则“^ /( {32})\。png $”不起作用(用于Apache)

我有这些重写规则(我尝试都没有用): location ~* "^/([a-z0-9]{32})\.png$" { rewrite ^ /index.php?page=log&id=$1 last; } 和 location ~* "/(?<hash>[a-z0-9]{32})\.png" { rewrite ^ /index.php?page=log&id=$hash; } 和 location / { try_files $uri $uri/ @rewrites; } location @rewrites { rewrite "^/([a-zA-Z0-9]{32})\.png$" /index.php?page=log&id=$1 last; #… } 基本上,我希望URL http://example.com/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.png实际上将parameter passing给我的index.php脚本,并在脚本中得到: $db->save_hash($_GET['id']); header('Content-type: image/png'); readfile('images/beacon.png'); break; 但是nginx给了我一个“未find”,但其他重写工作正常。 是什么赋予了?

无法重新启动php5-fpm

我在.ini文件中做了一些修改,并想重新启动php5-fpm。 /etc/init.d/php5-fpm重启 1月20 14:25:48.171577地址错误[错误] bind()/var/lib/php5-fpm/apps.sock失败:地址已经在使用(98) 我怎样才能找出使用这个地址的是什么? 我已经停止nginx,但没有任何改变。

Nginx的用户/组configuration

我是nginx的新手,但是在过去的几天里,我一直在学习这些function和所有function。 我在Centos 6.3中运行nginx。 我已经用php-fpm安装了nginx,但是有一些关于用户和组的问题。 当我安装nginx时,它将用户/组设置为nginx。 我已经设置了我的方框,让/accounts/example.com/public_html中的所有服务器阻止帐户(虚拟主机)。 现在的文件夹都是由根/根拥有我需要将任何文件夹更改为Nginx / Nginx? 设置php-fpm池帐户。 我有一个名为www.conf的/etc/php-fpm.d文件夹里有一个php-fpm conf文件。 该文件中的用户和组是www / www。 我假设这是默认的conf文件,如果我不运行池。 如果我不运行池应该用户/组更改为Nginx / Nginx的? 如果我打算运行php-fpm池,那么/etc/php-fpm.d/domainname.conf中的用户应该反映我在问题1中设置的相同用户/组。 nginx.conf中列出的用户/组是否应与php-fpmconfiguration相同? 我真的很困惑的用户和组的虚拟主机设置(我知道这是一个Apache的术语)我只是想弄清楚什么用户/组,我必须添加,什么文件夹的权限,我必须改变…等 如果有人可以给我一个小的FYI文件夹需要什么权限的设置我运行它会帮助我很多。 除非是日志文件/文件夹,否则Web上的所有教程似乎都会传递用户/组/文件夹权限。 任何帮助将非常感激! 谢谢!

Nginx FastCGI仅在子目录中?

我有一个单独的域,其中根由uWSGI下运行的python应用程序提供服务。 然而,我需要在子文件夹/论坛/上运行PHP论坛。 我在apps-availableconfiguration文件中有以下内容: location / { try_files $uri @oath; } location @oath { include uwsgi_params; uwsgi_pass 127.0.0.1:3031; } location /forum/ { alias /home/drake/forum; index index.php; } location ~ /forum/(.*)\.php { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } 然而, example.com/forum/ forum/被发送到uWSGI应用程序和example.com/forum/index.php ,同时被交给FastCGI,返回File not found. 并将以下内容logging到error.log : 2013/03/03 00:10:52 [error] 28102#0: *1 FastCGI sent in stderr: […]

让Nginx从PHP-FPM发送4xx / 5xx错误

我有Nginx安装程序来反向代理以.php结尾的所有文件。 在一些脚本中,我检查参数,并发送“406不可接受”作为一个通用的错误,这需要从Ajax的jQuery /拾起。 我可以改变这个错误,但我希望能够把它发送到客户端。 如果我发送406,Nginx会将其更改为502 Bad Gateway并注入它自己的错误消息。 它虽然适用于404和403,但这些错误在这种情况下并不真正“适用” 这是一个API,所以被禁止是不好的RESTful实践。 我尝试使用fastcgi_intercept_errors,但似乎没有区别。 我正在使用Nginx 0.7 。 PHP的一部分: header($_SERVER['SERVER_PROTOCOL'] . '406 Not Acceptable'); echo '{"error":"Missing Params"}'; exit; Nginxconfiguration location ~ .php$ { fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

软链接到网站

我有Nginx安装在Ubuntu上,我有下一个configuration文件: server { root /www/test; index index.html index.htm; server_name .dev.mysite.info; 我在/ www / test目录中有HTML文件,并且都正常工作。 现在我想将我的文件夹更改为软链接: lrwxrwxrwx 1 root root 33 Jun 17 10:39 test -> /root/Dropbox/digital_ocean/test/ 但是在浏览器中获取错误消息: "500 Internal Server Error" 为什么以及如何解决? 更新: root@ocean:/var/log/nginx# cat error.log 2013/06/17 11:40:27 [crit] 26197#0: *1 stat() "/www/test/" failed (13: Permission denied), client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", […]

检查nginx活动连接没有HttpStubStatusModule

我们要检查没有安装模块HttpStubStatusModule的活动连接的数量。 什么是等效的Linux命令? 作为一个基线,我们先在安装了HttpStubStatusModule的机器上进行testing,例如 Active connections: 6146 <– from HttpStubStatusModule # netstat -an | grep :80 | wc -l 1266 # netstat -an | grep :443 | wc -l 25082 在我看来,上面的netstat都没有给我正确的数字。 任何想法?

如何设置nginx和一个子域名

我有gitlab安装在我的服务器上,它适用于所有域名,例如:git.lars-dev.de,lars-dev.de和* .lars-dev.de我如何才能运行gitlab只git.lars-dev.de另一个子域名在files.lars-dev.de? 我的lars-dev conf: server { listen *:80; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 root /var/www/webdata/lars-dev.de/htdocs; index index.html index.htm; server_name lars-dev.de; location / { try_files $uri $uri/ /index.html; } #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /usr/share/nginx/www; #} […]

nginx:try_files找不到静态文件,回退到PHP

相关configuration: location /myapp { root /home/me/myapp/www; try_files $uri $uri/ /myapp/index.php?url=$uri&$args; location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/index.php; } } 我绝对在/home/me/myapp/www有一个文件foo.html ,但是当我浏览到/myapp/foo.html它由PHP处理,这是try_files列表中的最后一个回退。 为什么发生这种情况?