Articles of nginx

离线反向代理与Nginx

我正在使用Nginx反向代理来访问在线drupal服务器上的内容。 事实是,如果Nginx失去他的互联网连接,当我试图通过反向代理调用服务器,我希望他给我回一个错误代码,说他没有设法连接远程服务器,超时,但是我唯一回来的是302代码,所以不能使用proxy_intercept_errors进行捕获。 我想要的是:如果Ngnix由于任何原因(404,50x,根本没有互联网)无法访问服务器,我希望他给我一个很好的,特定的错误页面(如果错误代码400或更高,但如果Nginx不能访问互联网)。 我使用的conf是: # Reverse proxy for remote hosts # regex capture, $1 is hostname $2 is the rest of the URI location ~* /reverseproxy/([^/]*)(.*) { $$$RESOLVER_DNS_ADRESSES_TOKEN$$$ proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_redirect off; proxy_buffering off; proxy_set_header Host $1; proxy_cache_bypass 1; proxy_no_cache 1; proxy_intercept_errors on; # Tranform custom X-Cookie into regular […]

我如何获得一个服务器上的多个位置指令在nginx中工作?

我正在开发一个JavaScript web应用程序,它将驻留在目录“js”中。 它将被连接成一个文件,并被放置在“静态”文件夹中进行分发,但在我开发时,我希望目录“/ js”指向不在“静态”文件夹中的JavaScript源文件。 这是我的configuration文件nginx,并从我的理解应该工作: # Dev server. server { listen 1337; charset UTF-8; location /js { root /home/tomas/projects/streamcore/js; } location / { root /home/tomas/projects/streamcore/static; index index.html; } } 我可以访问“index.html”,但在“/ js”下的任何文件请求都以404 NOT FOUND结尾。 根据文档的请求应该匹配与最具体的模式,在这种情况下是“/ js”的位置块,所以我不明白为什么这是行不通的。 如有需要,请索取更多信息。 谢谢你的帮助。

Nginx上游 – 主服务器closures的通知

我希望有人能给我一些帮助,因为我对Nginx来说很新。 提前致谢。 前提:我在一个testing环境中有一个负载均衡服务器(nginx upstream),两个web服务器之间的负载平衡。 我使用fail_timeout参数,因为如果一台服务器出现故障,由于两者之间的数据完整性问题,我不能重新引入,直到我手动干预。 问题:我需要知道有问题的服务器已被取出循环。 电子邮件可能会问太多,但任何事件,我可以触发将是非常有益的。 注意:虽然我有系统监视服务器,如果出现故障,应该通知我,但是当Nginx“认为”某个服务器发生故障时,如果负载平衡服务器无法联系给定服务器,则更加重要。无论出于何种原因,监测系统都可以。

Nginx的代理caching(proxy_pass $ request_uri;)

我需要使用nginx创build代理网页。 如果我访问http://myweb.com/http://www.target.com/,则proxy_pass应为http://www.target.com/ 这是我的configuration: location / { proxy_pass $request_uri; proxy_cache_methods GET; proxy_set_header Referer "$request_uri"; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_ignore_headers Cache-Control; proxy_hide_header Pragma; proxy_hide_header Set-Cookie; proxy_set_header Cache-Control Public; proxy_cache cache; proxy_cache_valid 200 10h; proxy_cache_valid 301 302 1h; proxy_cache_valid any 1h; } 这是日志错误 2013/02/05 12:58:51 [error] 2118#0: *8 invalid URL prefix in "/http://www.target.com/", client: […]

转换.htaccess到nginx是打破我的应用程序

我一整天都在努力工作,而且还没有运气。 我用一个在线的.htaccess来configuration转换器,所以我不认为它正确地转换一切。 以下是我的.htaccess文件 RewriteCond %{QUERY_STRING} ^$ RewriteRule ^((.)?)$ index.php?p=home [L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ $1 [QSA,L] RewriteCond $1 !^(\#(.)*|\?(.)*|\.htaccess(.)*|\.htaccess\.back(.)*|.idea\/(.)*|.svn\/(.)*|admin\.php(.)*|content\/(.)*|download\.php(.)*|ecc\/(.)*|images\/(.)*|index\.php(.)*|install\/(.)*|login\.php(.)*|readme\.txt(.)*|robots\.txt(.)*) RewriteRule ^(.+)$ index.php?url=$1&%{QUERY_STRING} [L] 和我的转换nginxconfiguration try_files $uri $uri/ /index.php?url=$uri&$args; location / { if ($query_string ~ "^$"){ rewrite ^/((.)?)$ /index.php?p=home break; } if (-e $request_filename){ rewrite ^(.*)$ /$1 break; } rewrite ^(.+)$ /index.php?url=$1&$query_string break; } location […]

服务器上的WebDAV暴露来自其他服务器的ZFS数据

是否有可能在一台计算机上托pipeWebDAV服务器,并从另一台服务器上提取“数据”(文件夹和文件以及所有文件)? 像这样的东西: CentOS Proxy | ————-|————– | | | FreeBSD1 FreeBSD2 FreeBSD3 (ZFS Store) (ZFS Store) (ZFS Store) 如果CentOS代理是每个连接都可以访问的WebDAV服务器,那么这些文件实际存储在FreeBSD ZFS服务器上? FreeBSD服务器上的文件将被chrooted到每个用户/组。 如果这是可能的,那么怎么去解决这个问题呢? 当我问他们这些问题时,我很厌烦那些看着我很有趣的人。 我们的首选是使用NGINX,但我们会高兴地看看Apache。 另外,这个(FreeBSD上的ZFS)与CentOS / XFS上的GlusterFS或者FreeBSD / ZFS上的GlusterFS相比如何? 如果有区别,每个ZFS商店计划运行RAID-Z,除了运行RAID-Z3的两个(实际上有三个以上,并且想法是通过添加新的服务器能够有机地增长) 我们很想看到一些OpenStack Swift的自我修复能力,但是这将是理想的。 TIA

NGINX重写www.example.com – > example.com

我有一个问题,这是我的规则: server { listen 80; server_name example.com; rewrite ^/(.*) http://example.com/$1 permanent; } 但是Firefox会抛出错误:无限反弹 我想重写www.example.com – > example.com

是否有可能在nginxconfiguration中重写错误页面

我有我的nginxconfiguration文件中的以下内容。 error_page 503 http:path-to-my.rackcdn.com/maintenance.html; Rackspace Cloudfiles上存储了一个静态html文件的服务器。 我不喜欢的是如何将url更改为… rackcdn.com。 我宁愿重写url,所以域似乎保持不变。 是否有可能重写错误页面的url类似的东西 mydomain/maintanence 谢谢。

NGINX / fascgi-mono-server4 – 多个站点

这是我的/etc/nginx/sites-available/default : # Sample site server { listen 80; ## listen for ipv4 server_name web; access_log /var/log/nginx/web.access.log; location / { root /srv/www/web/; index default.cshtml Default.cshtml; fastcgi_index Default.cshtml; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; } } # Another Sample site server { listen 80; ## listen for ipv4 server_name irws; access_log /var/log/nginx/irws.access.log; location / { root /srv/www/irws/; index […]

Nginx的位置和根

我认为我有一个与Nginx的微不足道的问题,但我不能看到它。 我有以下文件树: /data/www > main/ >> html/ >>>…some files (A) > wiki/ >>…some files (B) 这是我的configuration: server { listen 80; server_name troll; root /data/www/main/html; location = / { index index.php; } location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/www/main/html$fastcgi_script_name; } location /wiki/ […]