Articles of nginx

403禁止

这是我的Nginxconfiguration: user pass users; worker_processes 1; events { worker_connections 1024; } http { passenger_root /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.7; passenger_ruby /usr/bin/ruby; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name some.another.ru; root /www/public/redmine; passenger_enabled on; rails_env development; } } 这里是Nginx的日志: 2011/06/02 12:53:57 [error] 45986#0: *1 directory index of "/www/public/redmine/" is forbidden, client: **.*.**.***, server: some.another.ru, […]

在nginx而不是上游服务器上处理404s

为了更高性能,我们希望允许nginx在传递给上游apache服务器之前捕获404。 两台服务器都有相同的文件。 更多信息 我们有一个stream行的设置,在nginx上提供静态内容,并使用apache上游来提供dynamic内容。 我们目前将PHP和静态文件同步到上游apache节点的nginx节点。 相同的文件位于两个图层上。 我们只提供来自nginx的静态文件。 目前,所有的非静态请求都会上传到Apache服务器(如以前所预期的那样)。 但是,我意识到在决定在上游传递它之前,nginx应该能够检查.php文件的存在。 这意味着更有效地处理请求。 我一直在尝试try_files的组合,然后最终如果块find解决scheme,但我没有成功。 请指教。 谢谢!

nginx重写configuration

我对nginx相当陌生,并试图设置一些非常简单的重写规则,但他们似乎并没有工作。 只是为了您的信息,这台server { .. }有它的server_name domain.com *.domain.com 。 我有这个rewrite ^ /index.php?/$request_uri; 这似乎很好。 这将匹配domain.com/asd/sad/sad,一切正常。 不过,我想做一些有趣的子域名…所以我有s1.domain.com和s198.domain.com但我想改变我的重写,所以它去/index.php?/s1/$request_uri如果这是有道理的? 所以子域在$request_uri之前。 这是我迄今为止所尝试的: if ($host ~* ^([az]+)\..*) { rewrite ^(.*)$ /index.php?/$1/$request_uri; } rewrite ^ /index.php?/$request_uri; 真的很感谢您可以给的任何帮助! 谢谢。

用nginx编码url

Nginx改变了我的服务器的行为。 我的configuration文件如下: server { server_name XXX ; location / { proxy_pass http://127.0.0.1:8080 ; } } server { listen 443; # ssl parameters server_name XXX ; location / { proxy_pass https://127.0.0.1:8081 ; } } 我的服务器回答显示所请求的url的页面。 当我尝试使用http:// XXX / a + b时 ,'+'变成了''(空格字符),而不是当我尝试https:// XXX / a + b并且确定它来自于nginx ,我尝试了https://127.0.0.1:8081/a+b和http://127.0.0.1:8080/a+b ,都显示“+”。 如何在nginxconfiguration中指定不解码/编码url?

nginx转发到不同的端口

好吧,我使用nginx来转发和从我的服务器和客户端的通信。 我的服务器通过端口6543接收通信,并且nginx将其转发到该服务器上的端口(从nginx代理服务器的端口80) 它工作正常,如果我inputhttp://mydomain.com/directory/ < – 注意尾部斜线 但如果我inputhttp://mydomain.com/directory < – 没有结尾斜杠 它变成http://mydomain.com:6543/directory/这当然不起作用,因为nginx服务器不期望在该端口上的任何东西。 我无法弄清楚如何解决这个问题。 帮帮我?

麻烦与nginxconfiguration和上游服务器

我试图configuration两个应用程序由nginx提供。 第一个似乎工作正常,我重复了第二个configuration,但我有一些问题。 我正在使用套接字运行由Unicorn支持的Sinatra服务器来传递上游信息。 我可以到达根域(api.richardson.co.nz),一切似乎工作正常,但只要我尝试访问根域(api.richardson.co.nz/games)path得到一个“找不到”的错误。 这是我的nginx conf文件: worker_processes 1; user nginx web; pid /tmp/nginx.pid; error_log /var/www/knowyourgenre.com/shared/log/nginx.error.log; events { worker_connections 1024; # increase if you have lots of clients accept_mutex off; # "on" if nginx worker_processes > 1 use epoll; # enable for Linux 2.6+ } http { include mime.types; default_type application/octet-stream; access_log /tmp/nginx.access.log combined; sendfile on; […]

Nginx龙卷风组合导致502错误的网关错误

我们正面临一个不一致的502错误的问题,并追查原因是一个非常令人沮丧的工作。 我们可以通过快速发送多个同时请求来重现问题。 问题是几个人在5秒内(而不是打字错误)只能在10到20的范围内。 所以这种types的负载应该很容易处理。 我们真的很喜欢Nginx + Tornado的方法,但是正在考虑采用更传统的方法(例如线程),因为这个问题很难解决。 我想知道如果你a)知道如何解决这个问题,b)我们如何能够追查到罪魁祸首。 日志文件只是标识连接被拒绝。 我们有这个职位相同的问题: https : //stackoverflow.com/questions/2962439/how-do-i-debug-a-http-502-error 但是如何解决这个问题还没有答案,所以我希望你能帮忙,因为这可能是这种types的设置常见的问题。 提前致谢, 保罗

摆脱“欢迎来到nginx!”

我刚刚在我的Ubuntu分段机器上安装了nginx。 inputhttp://192.168.1.1./index.php就像一个魅力,并加载我已经放在/var/www/public_html文件夹中的index.php文件。 http://192.168.1.1不过反而显示欢迎使用nginx! 页面,而不是我的index.php文件。 我究竟做错了什么? 这是我的nginxconfiguration: server { listen 80 default; root /var/www/public_html; index index.php index.html index.htm; server_name _; location / { try_files $uri $uri/ /index.html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; } }

nginx提供最新的下载

在我主持的网站上我有一个nginx设置为http服务器主要用于静态内容。 一些内容得到服务器实际上是软件下载(setup.exe的东西)。 我想要做的是以某种方式让nginx在静态URL下提供最新的下载包。 因此,只要myapp-setup-1.0.msi是相应内容目录中的最新文件, http://www.example.com/download/myapp就会导致myapp-setup-1.0.msi的下载。 我试图通过使用符号链接来实现这一点,但随后出现的问题是,必须设置一个适当的头(Content-Disposition),其中包含浏览器显示的文件名,而且我不知道如何从目录中获取符号链接的目标文件名nginxconfiguration。 我认为这可能是不可能的。 这是迄今为止的configuration: server { listen 80; server_name www.example.com example.com; access_log /var/log/nginx/download.access.log; location /download/ { alias /var/www/download/; default_type application/octet-stream; } location /download/myapp/ { alias /var/www/download/myapp/; index latest.msi; default_type application/octet-stream; if ($request_filename ~* ^.*/([^/]*?)$) { set $exits true; set $msi $1; } if ($msi = latest.msi) { set $msi "myapp-setup-1.0.msi"; } […]

ngingx允许单个IP和内部请求

我试图设置一个nginx服务器来允许来自单个IP的请求以及内部请求。 原因是这个盒子可能被直接命中,或通过proxy_pass。 我一直没有find一种方法来混合允许和内部。 在理想的世界中,我想要做这样的事情: location = /myFile.html { # allow to permit proxy_pass from other box allow XX.XXXX; # allow internal requests internal; # deny everything else deny all; } 我已经阅读了文档,并没有find合适的指令组合。