Articles of nginx

如果博客不在根目录下,Nginx和WordPress的永久链接就会被破坏

所以我在我的服务器上安装了nginx和Wordpress。 但是,我的博客不在域根。 (例如example.com/blog ,内容位于/var/www/example.com/blog ) 我在nginx中使用下面的设置,我的Wordpress安装使用Apache中的URL重写规则。 (例如像example.com/blog/2012/hello-world永久链接) 但是,有趣的是,所有这些URL重写规则都进入了/ (而不是在blog/ )中的index.php 。 我想解决,但我不知道如何。 另一个有趣的事情是, example.com/blog (主页)工作正常。 例如,因为example.com/blog/2012/hello-world不是真正的文件,所以try_files正在执行example.com/index.php 。 (url保持不变,但index.php得到执行)。 任何帮助表示赞赏! server { listen 80; root /var/www/example.com; index index.php; server_name 192.34.59.214; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass […]

用一个redirect去除www和.html

我有一个问题,如果用户键入: www.myurl.com/page.html 他们首先被redirect到 myurl.com/page.html 然后去 myurl.com/page 这是因为我在我的conf文件中有以下内容 #remove www from url if ($host ~* ^www\.(.*)) { set $remove_www $1; rewrite ^(.*)$ http://$remove_www$1 permanent; } location /{ # removes .html extension if ($request_uri ~ \.html($|\?)) { rewrite ^(.+)\.html$ $1 permanent; } } 我的问题 : 有没有办法消除第一次redirect,以便如果用户键入www.mysite.com/page.html他们直接redirect到mysite.com/page

Nginx没有运行。 没有得到任何错误

如果我运行: $ sudo service nginx status * nginx is not running 然后我运行: $ sudo service nginx start Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) … nginx: [emerg] still could not bind() 所以我杀了它: sudo fuser -k 80/tcp 所以我尝试再次启动Nginx: $ […]

Apache作为反向代理:同步还是asynchronous?

我使用Apache来提供静态内容,然后反向代理到Rails服务器来处理dynamic内容,其中一些可能需要很长时间才能生成。 当Apache向一个反向代理发出一个请求时,Apache进程已经用完了,只是坐在那里等待响应(即时使用prefork mpm),或者它可以closures并处理其他请求,只处理来自Rails服务器的响应当答复准备好了?

Nginx – 转发绝对url的请求

我正在寻求代理mapquest OSM瓷砖,所以我可以通过SSL为我的用户提供服务。 这是我的nginxconfiguration看起来像: upstream maptile_server { server otile1.mqcdn.com; server otile2.mqcdn.com; server otile3.mqcdn.com; server otile4.mqcdn.com; } server { # … server_name app.example.com; location /tiles { proxy_pass http://maptile_server; } } 因此,如果http://otile1.mqcdn.com/tiles/1.0.0/osm/14/3678/6230.png中存在地图图块,我想通过https://app.example.com/tiles访问它/1.0.0/osm/14/3678/6230.png 。 目前,我收到了一个“无效的url”错误。 编辑: 我也考虑过这样做: location ~ /maptiles/(?<subdomain>.+)/(?<z>.+)/(?<x>.+)/(?<y>.+) { return http://$subdomain.mqcdn.com/tiles/1.0.0/osm/$z/$x/$y; } 但是这将redirect到最终的url而不是代理请求。 有没有办法隐藏客户端的最终URL?

nginx,apache httpauthentication

我有一个nginx反向代理服务器,与apache后端进入清漆caching。 这个php作为一个从apache开始的fastcgi进程运行。 我试图让一些PHP软件工作,但基本的HTTP身份validation对话框不接受任何用户名或密码。 我做了一些挖掘,并想出了这个.htaccess文件: RewriteEngine On RewriteRule .* – [E=REMOTE_USER:%{HTTP:Authorization},L] 这已经解决了基本HTTPauthentication的authentication问题。 现在我一直在试图弄清楚到底做了什么,所以我的问题是:为什么添加这个重写规则使authentication开始工作? 我现在所能想到的就是在nginx – > varnish – > apache链的某个地方,apache没有收到auth头文件。 我想了解这里发生了什么事情,所以我可以在服务器级别实施更改,以防止其他地方发生。 有人可以澄清? 谢谢

Nginx:位于不同根目录下的try_files的位置404

我正在将我pipe理的wiki(practicalplants.org)移动到运行Nginx的新服务器上。 我习惯于Apache; 这是我第一次和Nginx一起工作,而且我无法适应我在Apache中设置的重写和别名。 目录布局如下 /html (server root) /html/w (mediawiki) /html/community (vanilla) /html/blog (wordpress) /sso (Zend Framework SSO solution) /sso/public 正如你所看到的,sso解决scheme有它自己的可公开访问的应用程序根目录,我试图将它设置为location指令的root ,但似乎下面的try_files仍然试图回退到server root 。 这是我的configuration: server { server_name practicalplants.org; root /var/www/v-practicalplants/html; access_log /var/log/nginx/practicalplants.org-access.log; error_log /var/log/nginx/practicalplants.org-error.log; include /etc/nginx/biowikifarm_listen80_443.conf; include /etc/nginx/biowikifarm_generics.conf; include /etc/nginx/biowikifarm_generic_php.conf; disable_symlinks off; location = / { # Redirect domain-only access to wiki: rewrite "^[/]?$" /wiki/ […]

Nginx不立即caching页面

我正在使用Nginx的proxy_cache模块进行caching,但注意到页面不会立即caching。 内容是非常dynamic的,每个页面加载产生不同的布局,我试图caching布局一个小时。 Nginx似乎只是快速地处理多个请求后caching页面。 这是我的configuration。 proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=1000m; #caching proxy_temp_path /var/tmp; #caching proxy_cache_valid 404 500 1m; proxy_cache_valid 200 60m; proxy_cache_min_uses 1; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_buffers 16 8k; upstream staging { server 127.0.0.1:1337; server 127.0.0.1:7331; } server { listen 0.0.0.0:80; server_name […]

Nginx错误日志大小为96GB

今天我的服务器没有响应HTTP请求,看起来像是因为nginxclosures,因为当我重新启动nginx,它再次工作。 我想看看错误日志,看看有什么问题,但它是97千兆字节 : -rw-r—– 1 www-data adm 106614104064 Mar 23 00:52 error.log 任何人都可以推荐一种方法来pipe理这种日志? 我显然不能从服务器上下载,当我尝试在nano / vi中打开时,terminal只是无响应。 我正在考虑在其上运行一个日志parsing器并使用它,但是我敢说在一个接近100GB的文件上花费很长时间。 编辑:经过一些挖掘后,似乎nginx崩溃的原因是因为它的日志占用所有可用的磁盘空间,所以它一直是一个错误,使nginx日志logging到错误日志,因为我的网站没有得到很多的交通。

Nginx的位置精确匹配超越了争议

在我的nginxconfiguration中,我想捕捉/ foo /并使用位置进行重写,但忽略/ foo / anything-else 我试过了: location = /foo-bar/ { 和 location ~ ^/foo-bar/$ { 和 location ~ /foo-bar/ { 但它也捕捉并重写 /foo-bar/?t=aaa-bbb-ccc 我怎么只捕捉 /foo-bar/ 并不是 /foo-bar/?t=aaa-bbb-ccc ? 谢谢。