Articles of nginx

Nginx的1.5.1支持spdy,passenger和php

我不明白,如果spdy已经与nginx 1.5.1打包在一起,或者我有重新编译它。 我用下面的命令安装了nginx:passenger-install-nginx-module这个安装了nginx 1.4.1,但没有将spdy模块编译进去。 php-fpm只能在nginx上安装,但是乘客和spdy必须被编译成二进制文件。 我希望任何人都可以指出我如何编译nginx的客运和spdy支持的正确方向。

是否应该阻止Nginx的上游服务器可以直接访问?

假设您使用Nginx和两个上游服务器www1.example.com和www2.example.com来提供example.com。 什么是正确的方式(不)暴露您的上游服务器? 隐藏wwwX.example.com是否很重要? 如果没有通过example.com的Nginx(例如代理)进行访问,您是否将wwwX.example.com设置为redirect到example.com? 或者你使用rel =“canonical”链接? 或者是其他东西 ?

使用Nginx重写防止Google图片search热链接

Google图片search能够指向原始图片,而不显示托pipe图片的网站。 所以我想将这些请求redirect到我的网站的自定义页面。 基本上我想重写所有这些url(谷歌提到): www.website.com/folder1/folder2/year/month/day/ID/string.jpg redirect到: www.website.com/ID/page.html 我试过这个代码: set $button_redirect 0; if ($http_referer ~ "\.google\.") { set $button_redirect 1; } if ($http_referer ~ "\.google\.[^/]+/blank\.html") { set $button_redirect 0; } if ($http_user_agent ~ "Googlebot|bingbot|Slurp|Baiduspider|Yandex|Sogou") { set $button_redirect 0; } if ($button_redirect = 1) { rewrite ^(.*)/folder1/folder2/([0-9]{4})/([0-9]{2})/([0-9]{2})/([0-9]+)/(.*)\.jpg$ /index.php?/$4/page.html last; } 但是当我重新启动服务器时没有加载单个页面,所以我认为我至less犯了一个错误。 你可以帮我吗? (我正在运行Codeigniter)。 我从这里取了大部分代码: http : //pixabay.com/en/blog/posts/hotlinking-protection-and-watermarking-for-google-32/ 。

如何阻止从匿名代理到我的网站的交通?

一些骗子正试图使用​​匿名代理访问我的网站。 有没有办法阻止从haproxy或nginx的匿名代理连接? 谢谢

Nginx + php5-fpm + CodeIgniter响应太慢

我在Ubuntu 12.04 LTS上安装了nginx,php5-fpm和setup codeigniter以及REST控制器。 即使只有一个用户,configuration也能正常工作,但响应时间太慢。 有时候nginx会用504状态码来回应。 请在下面find我的configuration文件的片段。 另外,如果我需要提供更多的configuration信息,请告诉我。 谢谢。 location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.php; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny […]

安装后找不到Ajenti

我只是安装了Ajenti到我的服务器,运行nginx。 我有一个域名已经设置好,除了Ajenti之外,一切都正常。 我将这个configuration添加到nginx,以达到Ajenti: server{ listen 80; server_name ajenti.XY.dk; access_log /XY/_log/ajenti.access.log; error_log /XY/_log/ajenti.error.log; add_header Strict-Transport-Security max-age=2592000; location /* { rewrite /* http://127.0.0.1:8000 permanent; } } 是的,我添加了一个符号链接到启用网站。 但是我无法从外面find它。 我尝试在服务器上的Linx,它打开Ajenti,所以它正在运行。 我应该改变我的configuration?

Nginx的fastcgicachingconfiguration

这里是http {}中的cachingpathconfiguration fastcgi_cache_methods GET HEAD; fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=website:10m inactive=1d max_size=10m; 这是虚拟主机中的configuration: location ~* \.php$ { fastcgi_index index.php; fastcgi_pass unix:/var/run/php5-fpm/manageraddons.socket; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_cache website; fastcgi_cache_key $host$uri$is_args$args; fastcgi_cache_valid 200 301 302 304 40s; fastcgi_cache_valid any 5s; } 我创build了一个简单的PHP文件,包括以下几行: <?php echo time(); ?> 所以,我的意图是:当我第一次访问它时,会打印出当前时间。 由于页面现在被caching,下次尝试访问页面时,应显示较早的时间,而不是当前时间。 但每次刷新页面时,打印的内容都会更改为。 我需要停止nginx向fastcgi发送请求,如何正确configurationnginx来做到这一点? 谢谢。

使用nginx重写指令保留URI

我是nginx的新手,我重写了一些指令,把主机名redirect到其他主机名。 我想保留在redirect的请求中的URI,例如http://www.johntate.org/blog转到http://johntate.org/blog等等。 目前我只有这个… server { listen 80; server_name www.johntate.org; rewrite / http://johntate.org/; } 我想要一些更复杂的东西来保存请求并转发它。

需要来自所有远程(非本地)客户端的SSL客户端证书?

我有一个nginx服务器,我想添加客户端SSL证书authentication。 我使用一个系统(GitLab),需要在内部调用自己的提交钩子等。 有没有一种方法来为所有远程 (而不是本地)客户端设置SSL与客户端SSL? 我想让GitLab可以在没有客户端证书的情况下自行调用,但所有的远程客户端都必须使用客户端的SSL证书进行身份validation。

如何通过厨师更新nginx

我是最近inheritance了我们以前的devops人的厨师设置的开发人员。 我正在运行Chef 10服务器,并且意识到opscode的nginx cookbook仍然使用nginx 1.2.6版本。 由于已经发布了很多安全补丁,我想转到1.4.1,觉得主厨应该很容易。 然而它已被certificate是噩梦。 我的第一个想法是简单地将nginx的食谱“定制”,并将default['nginx']['version']属性更改为1.4.1,上传食谱并汇集testing服务器。 我看着它取得新版本的食谱(我记得要更新元数据),并且在1.2.6版本中继续忽略它。 然后我想我应该重写我正在使用的angular色的属性(rails_tier_web是angular色的名称)。 与一位更有经验的厨师人员谈话时,他提醒说不要这样做,因为angular色不能按照烹饪书的方式进行版本pipe理。 不过,阅读cookbook的文档,他们告诉你在你的angular色中使用override属性,这就是我所做的: override_attributes( 'nginx' => { 'source' => { 'version' => '1.4.1', 'prefix' => '/opt/nginx-1.4.1' }, 'version' => '1.4.1' } ) 但是当我收敛的时候,我仍然在日志输出中看到1.2.6的痕迹。 [2013-07-15T18:52:03-04:00] INFO: Processing remote_file[http://nginx.org/download/nginx-1.2.6.tar.gz] action create (nginx::source line 56) [2013-07-15T18:52:05-04:00] INFO: remote_file[http://nginx.org/download/nginx-1.2.6.tar.gz] updated 然后在那之后 Mixlib::ShellOut::ShellCommandFailed ———————————— Expected process to exit with [0], but […]