Articles of nginx

nginx多域名select性工作

这是我的第一个问题! 几天前,我发现nginx出了点问题:域AC好,其他的超时。 之后:其他域名可以,第一次超时; 或者每个域都工作正常。 如果我重新启动nginx – 没有任何改变。 重新启动后,一切正常。 也许是因为有时候访问者和nginx的连接太多而无法处理? (以前有一个Apache,它偶尔冻结VDS)。 但是在日志中没有错误,没有什么。 在最高输出中,我看到只有2-4mb的交换空间被使用。 它是:arch linux,nginx,php-fpm。 configuration文件:用户http http; worker_processes 1; error_log /var/log/nginx/nginx.error.log; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; error_log /var/log/nginx/http.error.log; sendfile on; gzip on; gzip_static on; gzip_vary on; client_body_buffer_size 1k; client_header_buffer_size 1k; client_max_body_size 5m; large_client_header_buffers 2 1k; client_body_timeout 10; client_header_timeout 10; keepalive_timeout […]

nginx不听80端口

我刚刚安装了Ubuntu 12.04服务器和nginx 1.2.7,从启用了网站的站点中删除了default ,并将我自己的文件添加到站点 – 启用sites-available链接和符号链接。 然后重新启动nginx。 问题:然而去URL不会加载网站。 netstat -nlp | grep nginx netstat -nlp | grep nginx和netstat -nlp | grep 80 netstat -nlp | grep 80都返回没有结果! lsof -i :80也不返回任何内容。 从另一台服务器dig返回正确的IP地址,所以它不应该是一个DNS问题。 我能够连接到我已经停止其服务的Apache。 nginx日志也没有显示。 我应该如何解决这个问题? /etc/nginx/site-available/mysite.com server { listen 80; server_name www.mysite.com mysite.com *.mysite.com; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /var/www/mysite/public; index index.php index.html; location / { […]

Nginx目录后

这是我正在处理的遗留代码,我不能改变它发布到哪里,所以我只需要找出一个方法。 一点的Javascript做一个职位如下 – POST /authentication/login/ 这是非常奇怪的,因为它张贴到一个目录,但无论如何,我想configurationNginx接受到这个位置的post,然后将它们传递给我的Nginxconfiguration中的一点PHP我有以下内部一个http块 server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location /authentication/login/ { index hello.php; #root html; #index /usr/local/nginx/html/hello.php; } location ~.php$ { include /usr/local/nginx/conf/fastcgi_params; fastcgi_pass 127.0.0.1:9000; } } PHP的东西的作品,我可以直接进入hello.php和那个作品。 我的错误日志/访问日志并不真的给我很多。 我在hello.php上得到了一个404,但是通过放入“index”来解决这个问题。但是,这永远不会导致PHP的调用。 我也尝试把fastcgi的东西放入nginx.conf中的/ authenticate / login / location。 关键在于,如果我发布一些/ […]

是否可以dynamic设置nginx上传模块的upload_store值?

我的服务器上有很多硬盘,我想上传文件。 由于将file upload到一个驱动器然后将其移动到另一个驱动器上,我想直接将file upload到它应该存储的驱动器上的临时文件夹。 location /upload/(.*)$ { upload_store /home/hoster-node/data/$1/tmp/; 我尝试了这样的想法将文件发布到/upload/sda2或其他东西,然后将临时文件存储在那里。 但是,当尝试启动nginx时,我遇到了这样的失败: Restarting nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: [emerg] mkdir() "/home/hoster-node/data/$1/tmp/" failed (2: No such file or directory) nginx: configuration file /etc/nginx/nginx.conf test failed 如果当然我可以继续创build24个不同的位置指令以及所有其他的东西,每个驱动器一个… 但是我打算在一个很大的系统中做这个,我想用他们的文件系统uuids来组织驱动器,所以这实际上是不切实际的。 只有一个最后的措施措施。 还是比每次将文件从系统驱动器移动到存储驱动器更好… 任何inputappriciated!

使用nginx:需要来自公共IP的请求authentication,本地不需要authentication

我写了一个简单的文件浏览器应用程序,使用端口3000上的节点服务。我使用nginx作为代理此服务的前端。 这是在我的家庭服务器上。 当我通过公共IP访问它时,我希望能够要求基本的HTTP身份validation,但是当我在家时不能。 我有这样的configuration: location /files { satisfy any; allow 10.1.0.0/24; deny all; auth_basic "Authentication Required"; auth_basic_user_file /etc/access_list; proxy_pass http://127.0.0.1:3000/; } 但是,这是行不通的。 当我在同一子网上的家庭networking上时,仍然要求我进行基本的HTTP身份validation。 我曾经认为命令“allow> deny> auth”配对“满足任何”是正确的。 我在这里做错了什么? 这可能吗?

configurationnginx为tomcat / uWSGI代理

我正在为java和django开发configuration一台amazon EC2机器。 我们select的栈是nginx作为80端口上的顶级监听器,并将请求传递给相应的应用程序,thro:8080代表tomcat,thro代表uWSGI的.sock。 我有nginxconfiguration如下: server { listen 80; server_name test.myproject.com; rewrite ^/(.*)$ /myproject/$1; location / { proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name test.myotherproject.com; rewrite ^/(.*)$ /myotherproject/$1; location / { proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name web1.myhost.com.br; location […]

Nginx webdav没有显示带有特殊字符的文件/文件夹

我有Nginx的WebDAV模块工作,一切都是正确的,除了包含任何方括号的文件或文件夹]或[ 。 该文件/文件夹从不显示在列表中。 我从来没有与Apache的这个问题,所以我猜测,Apache正在做一些自动重写。 但是现在,我需要使用nginx。 我只是意识到它不适用于char ª 显然,这是一个有关逃避某些字符的问题。 使用Web浏览器可以工作,但从不使用WebDAV客户端(Cyber​​duck,Transmit,OSX Finder …) 这是我的configuration文件: server { server_name my.server.com; root /home/web/dav; dav_methods PUT DELETE MKCOL COPY MOVE; dav_ext_methods PROPFIND OPTIONS; auth_basic "Description"; auth_basic_user_file /etc/nginx/passwd.dav; location / { autoindex on; client_body_temp_path /var/www/php5fpm/tmp/client-tmp 1 2; create_full_put_path on; client_max_body_size 50m; dav_access user:rw group:r all:r; } } debugging信息: 网页浏览器: http : //drop.difun.de/Chrome.png […]

如何在保持地址栏中的URL的同时将根目录redirect到子目录

我有一个像这样的文件夹结构的nginx设置: – www |- splash |- blog www是根文件夹。 我想将访问http://example.com用户redirect到splash文件夹。 但我不希望地址栏中的url更改为http://example.com/splash 。 地址栏中的url仍应为http://example.com 。 此规则只适用于用户访问根文件夹。 同时访问blog文件夹将像往常一样通过: http://example.com/blog : http://example.com/blog 。 我如何做到这一点? 到目前为止,我的conf是如下:(他们不工作btw,URL被改变) server { listen 80; server_name www.example.com; root /www; location = / { rewrite ^/(.*)$ splash/$1 permanent; } }

尝试访问mailman listinfo和admin在nginx时出现常量403错误

我已经通过这个教程build立了nginx和mailman(其他的): http : //www.howtoforge.com/perfect-server-ubuntu-12.04-lts-nginx-bind-dovecot-ispconfig-3-p4 我成功地创build了一个邮件列表(名为braindexter-pre-registration ),并收到了欢迎邮件,但每当我尝试访问pipe理页面添加成员或发送电子邮件时,我都会得到一个(大部分)空白页面说403 。 如果我访问http://192.168.1.12:8081/cgi-bin/mailman/admin/braindexter-pre-registration ,如果我访问http://192.168.1.12/cgi-bin/mailman/admin/braindexter-pre-registration ,我只是得到欢迎使用nginx! 屏幕。 以下是我使用8081端口时的错误日志: 2013/07/24 19:10:35 [error] 12255#0: *32 FastCGI sent in stderr: "Cannot chdir to script directory (/usr/lib/cgi-bin/mailman/admin)" while reading response header from upstream, client: 192.168.1.11, server: _, request: "GET /cgi-bin/mailman/admin/braindexter-pre-registration HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host: "192.168.1.12:8081" 以下是我使用80端口时的访问日志: 192.168.1.11 – – [24/Jul/2013:19:12:31 -0500] "GET /cgi-bin/mailman/admin/braindexter-pre-registration HTTP/1.1" 304 […]

查找nginx在请求处理的每一步中花费了多less时间

我们使用Nginx作为服务于.NET WCF应用程序的IIS后端服务器的反向代理。 最近我注意到了开销响应时间的降低。 我的意思是我曾经在$ request_time和$ upstream_response_time之间看到6ms的差异,现在我在22ms。 活动连接的数量没有增加,请求数量,大小,响应大小都没有增加。 CPU和磁盘IO非常低。 networkingstream量似乎也很好。 我试过了 : 禁用SSL,不变。 将nginx的configuration更改回默认值,不变。 机器从零开始重build,没有变化。 原始configuration和开销较慢的VM非常低,+/- 6ms。 我怎样才能调查这个问题…? 有没有办法看看nginx花了多less时间在请求处理的每一步? 在debugging模式下查看error.log,找不到这个答案。 谢谢