Articles of nginx

我不能限制对nginx目录和子目录的访问

你能帮我用我的nginxconfiguration文件吗? 问题是:我无法限制对目录的访问,只能访问一个文件。 这行工作: location ^~ /wp-admin/index.php { (But only for one file) 这种方式不起作用: location ^~ /wp-admin/.+\.php { 我也试过这个: location ~ /(wp-admin) { 为什么?? 我的代码: server { listen 80; server_name www.server.com; access_log /var/www/server.com_access.log; error_log /var/www/server.com_error.log; server_tokens off; set $webroot '/var/www/server.com'; set $indexfile 'index.php'; root $webroot; #Static IMAGES files location location ~* ^.+\.(jpg|jpeg|gif|png)$ { valid_referers none blocked […]

Nginx不能回应

我已经在Windows Server 2012上设置了WNMP,尽pipe事实上它并不是那么需要的设置,以下是我的设置: worker_processes 1; error_log logs/error.log; #pid logs/nginx.pid; events { worker_connections 1024; } http { fastcgi_read_timeout 2m; fastcgi_ignore_client_abort on; include mime.types; default_type application/octet-stream; access_log off; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; ssl_session_timeout 10m; ssl_protocols TLSv1.2 TLSv1.1 TLSv1 SSLv3; ssl_ciphers ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH; ssl_prefer_server_ciphers on; #gzip on; # http server server { listen 80; listen […]

如果通过域进行请求挂起

我有一个应用程序,用户可以使用githublogin。 当我login时,应用程序挂起大约一分钟。 这是日志 Started GET "/" for 177.97.171.165 at 2013-08-11 15:26:01 +0000 Started GET "/sessions/new" for 177.97.171.165 at 2013-08-11 15:26:03 +0000 Started GET "/auth/github" for 177.97.171.165 at 2013-08-11 15:27:03 +0000 (github) Request phase initiated. Started GET "/auth/github/callback?code=ade18bb431c9303c6274&state=deaf138aff766c6ec3480a54897ae8bbbe734e0dfe11790d" for 177.97.171.165 at 2013-08-11 15:27:05 +0000 (github) Callback phase initiated. Started GET "/" for 177.97.171.165 at 2013-08-11 15:28:06 […]

Nginx代理的websockets,连接不封闭

我对这个问题的位置感到困惑,但基本上我把nginx代理websocket连接到一个后端ruby瘦服务器,后者在Ruby on Rails应用程序中用websocket-rails模块来连接服务。 除了可能所有的套接字都没有closures以外,其他所有的工作都可以正常工作,所以瘦服务器相对较快地耗尽了文件描述符。 我正在使用nginx 1.4.2,这是我的configuration: map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen my.ip.num.ber:80; server_name admin3.mydomain.com; root /home/apps/mydomain/current/public; try_files $uri/index.html $uri @admin3.mydomain.com; access_log /var/log/nginx/admin3.access.log combined; error_log /var/log/nginx/admin3.error.log error; location /websocket { proxy_redirect off; proxy_pass http://localhost:3008; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header […]

Gitlab前端公开“chrooted”

我有2台服务器: 第一:包含gitlab + apache代理,在我的内部networking域git.development 第二:服务器前端只有nginx,在我的公共领域git.mydomain.com上 我想在第二台服务器上的“公共”目录“chrooted”的gitlab。 公共Web服务器的目录“公共”基础:git.development / public —-> git.mydomain.com 无需login即可redirect到基础:git.mydomain.com/users/sign_in —-> git.mydomain.com 目前我有一个部分的设置: 在服务器1上的Apache(工作没有问题) <VirtualHost *:80> ServerAdmin [email protected] ServerName git.development ProxyRequests Off <Proxy http://127.0.0.1:8082/*> Order deny,allow Allow from 192.168.0. 127.0.0.1 </Proxy> ProxyPreserveHost On ProxyPass /uploads ! ProxyPass /error ! ProxyPass / http://127.0.0.1:8082/ CustomLog ${APACHE_LOG_DIR}/development.3.git.access.log combined ErrorLog ${APACHE_LOG_DIR}/development.3.git.error.log # Modify path to your needs […]

旅客apache和nginx模块不能编译在Ubuntu的12.04LTS

我正在从根帐户做这一切。 我遵循这个指南: https : //www.digitalocean.com/community/articles/how-to-install-rails-apache-and-mysql-on-ubuntu-with-passenger 我已经尝试挂载额外的交换空间,因为服务器只有512MB的RAM(半共享,一半“我的”)。 我已经安装了乘客安装指南所依赖的软件。 当我运行passenger-install-apache2-module和rvmsudo passenger-install-nginx-module时,在检查过程中我得到了所有的绿色,然后发生了最后的事情,在它经常停顿很长时间,然后踢我离开ssh会话: mkdir -p buildout/common/libpassenger_common/ApplicationPool2 g++ -Iext -Iext/common -Iext/libev -Wno-ambiguous-member-template -D_REENTRANT -I/usr/local/include -DHAS_TR1_UNORDERED_MAP -DHAVE_ACCEPT4 -DHAS_ALLOCA_H -DHAS_SFENCE -DHAS_LFENCE -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-missing-field-initializers -ggdb -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -fcommon -feliminate-unused-debug-symbols -feliminate-unused-debug-types -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -Wno-attributes -o buildout/common/libpassenger_common/ApplicationPool2/Implementation.o -c ext/common/ApplicationPool2/Implementation.cpp Write failed: Broken pipe 我拉头发,但没有多大帮助。 似乎没有任何使用我的谷歌福的这个问题的痕迹,所以我猜我在早期的FUBAR'd服务器。 但我真的只是试图安装rails,所以没有很多其他的东西。 如果有问题,我在RVM上有ruby。 有任何想法吗? 编辑:ps […]

将子文件夹redirect到子文件夹,并通过nginx删除子文件夹

我试图用nginx将子文件夹redirect到另一个子文件夹。 困难的部分是从显示目标子文件夹中删除,因为它是一个ruby应用程序,而不是一个真正的根文件夹。 他们都在同一台服务器上,我明显控制这两个域 例如:www.example1.com/exampleredirect到www.example2.com 我做的最远,但我知道这是不正确的.. if ($request_uri ~* ^\/example) { rewrite ^\/example http://example.com permanent; } 记住没有物理根源是很重要的。

nginx passenger_root不接受有效的乘客gem位置

我试图将passenger_root和passenger_ruby添加到我的nginx.conf文件中,但是当我尝试并重新启动NGINX时,我收到消息: Starting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable (/usr/lib/phusion-passenger/agents/PassengerWatchdog) does not exist. This probably means that your Phusion Passenger installation is broken or incomplete, or that your 'passenger_root' directive is set to the wrong value. Please reinstall Phusion Passenger or fix your 'passenger_root' directive, whichever is applicable. (-1: […]

Nginx编译与couchbase-nginx模块高CPU使用率

我正在用ngx_srcache模块testingcouchbase_nginx模块以将数据存储在couchbase中。 我使用https://github.com/couchbaselabs/couchbase-nginx-module根据指南编译和安装安装程序,没有任何问题。 经过几次浏览Nginx的CPU使用率达到100%,浏览器客户端无法下载剩余的数据和Nginx进程冻结。 这是我的configuration # ./sbin/nginx -V nginx version: nginx/1.3.7 built by gcc 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) configure arguments: –prefix=/opt/nginx-couchbase –with-debug –add-module=../nginx- couchbase-module-0.3.1 –add-module=./contrib/srcache-nginx-module-master –add-module=./contrib/memc-nginx-module-master nginx.conf: …. location /cb { internal; set $couchbase_key $arg_key; set $couchbase_cmd $arg_cmd; set $couchbase_val $arg_val; couchbase_connect_timeout 6ms; couchbase_timeout 3ms; add_header X-Couchbase-Flags $couchbase_flags; couchbase_pass localhost:8091,127.0.0.1:8091,localhost bucket=default; } location / […]

Gunicorn错误:“打开文件读取错误:权限被拒绝”

运行我的Django应用程序时,出现错误:当我发出超过7800字节的请求时,我看到gunicorn出现以下错误: "Error opening file for reading: Permission denied". 然后它丢弃请求,并且nginx得到“连接重置由同辈”错误。 如果我运行Django开发服务器,这不会发生。 奇怪的是,如果我向一个无效的URL发出请求,无论发布什么内容长度,我都会得到标准的Djangodebugging网页。 因此,似乎是gunicorn如何处理Django在处理有效的查看URL请求时正在做的事情。 这是在Ubuntu 12.04上运行。 我已经尝试运行Gunicorn作为根,它仍然发生。 我在进一步的debugging方面有点不知所措。 我试着设置tmp_upload_dir到一个目录将完全权限incase这是一个问题,但没有运气。 任何build议真的会被赞赏。