我有3台服务器。 第一个服务器(CPU – 型号名称:06/17,2.66GHz,4核,8GB RAM)有nginx作为负载平衡器,下一个configuration upstream lb_mydomain { server mydomain.ru:81 weight=2; server 66.0.0.18 weight=6; } server { listen 80; server_name ~(?!mydomain.ru)(.*); client_max_body_size 20m; location / { proxy_pass http://lb_mydomain; proxy_redirect off; proxy_set_header Connection close; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass_header Set-Cookie; proxy_pass_header P3P; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } } 并从nginx.confconfiguration: […]
我试图用ab来衡量nginx上的perfornace。 从本地计算机执行相同的ab操作,使我从位于同一networking上的远程计算机获得的每秒请求数大约是每秒10次。 Local results: Server Software: nginx Server Hostname: 192.168.0.116 Server Port: 8000 Document Path: /data/adpix/picture/test.jpg Document Length: 4602 bytes Concurrency Level: 1000 Time taken for tests: 1.475 seconds Complete requests: 10000 Failed requests: 0 Write errors: 0 Total transferred: 49854651 bytes HTML transferred: 46622862 bytes Requests per second: 6778.38 [#/sec] (mean) Time per request: […]
直到这一点,我一直在使用独立的乘客(基于nginx的)为我的应用程序。 一切工作正常。 我决定转向基于nginx的解决scheme,因为我需要能够支持多个站点。 我遵循通常的指南,使用乘客nginx安装,一切工作正常。 我configuration我的nginx如下: server { listen 80; server_name www.mydomain.com; root /www/myproject/public; passenger_enabled on; } 服务器按预期启动,但每次访问www.mydomain.com时,服务器都会返回一个500。 似乎事情是按照预期开始的,因为我曾经忘记启动mongo守护进程,并且得到了一个乘客错误,表示无法连接到mongo服务器。 所以至less它运行着SOMETHING。 一旦我开启了守护进程,它又回到了500s。 我检查了日志,我的logs/production.log什么都没有。 Nginx在error.log没有任何内容, access.log有这样的内容: xxx.xxx.xxx.xxx – – [22/Feb/2012:11:14:51 -0500] "GET / HTTP/1.1" 500 643 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.9) Gecko/20110412 CentOS/3.6.9-2.el6.centos Firefox/3.6.9" 我的mongo日志正在吐出通常的东西: Wed Feb 22 11:14:44 [initandlisten] connection accepted from 127.0.0.1:47013 #1 […]
目前,我有nginx> 25 x nginx + fcgi 主要的nginx,负载平衡和每个虚拟主机听不同的ip(不同的产品)。 一些ips会收到不同的主机名,并将它们重写回到后端服务器,如: … http://some-random-url.com/path GET /pathHTTP / 1.1 主持人:app1 X-Original-Host:some-random-url.com X-Forwarded-For:12.34.56.78 …. 我们正在用haproxyreplace主代理(更好的负载平衡algorithm),但我不知道如何附加原始主机。 (我找不到像nginx的$ host这样的variables的任何文档)。 我可以重写像这样的url: reqirep ^主持人:主持人:\ app1 但“app1”仍然需要原始的主机名来做业务逻辑。 我想在不同的端口上运行每个应用程序,但问题是,我希望nginx的httpchk适用于所有的后端服务器,每个应用程序做一个backend意味着每个backend每秒10个应用程序x 10次检查= 10次检查(除非日志数据说谎)。 任何人有一个想法?
我刚刚用php5-fpm安装了nginx,并且使用一台虚拟主机服务器就可以正常运行。 我刚刚添加了一个wordpress安装(不同的域名)的辅助服务器,当我去它,它总是redirect到第一个虚拟主机已经一直工作。 奇怪的部分是,在错误日志中,我可以看到它从wp-content加载内容失败,但它试图从第一个领域拉… 第一个领域和一个始终如一的作品: server { listen 80; server_name domain1.com; rewrite ^ https://$server_name$request_uri? permanent; } server { # Change these settings to match your machine listen 443; server_name domain1.com; # Everything below here doesn't need to be changed access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /data/www/domain1.com/www/; index index.html index.htm index.php; ssl on; ssl_certificate /data/ssl/domain1.pem; ssl_certificate_key /data/ssl/domain1.key; ssl_session_timeout […]
我需要一个Nginx的重写规则,它将重写所有的图像: http://mysite.com/index.php/article/foo/images/image.(png|jpg|gif) 讲话: http://mysite.com/images/image.(png|jpg|gif)
我正在configurationnginx与secure_download一起工作,并使其工作没有任何问题。 不过,我想修改它,只为特定的IP做下载链接。 我可以使用$remote_addrvariables来实现这一点。 不过有一些ISP知道我经常更换IP(每2或3秒一次)。 我的ISP也这样做,例如: 我现在得到了112.112.11.11作为我的IP,刷新后会是112.112.11.17 。 这个行为是由ISP设置的,而不是由我的调制解调器或路由器设置的,我知道还有几个ISP也这样做。 现在,IP变化太快,安全下载将无法正常工作,因为在加载页面时,IP可能已经改变,导致下载链接对新IP无效。 我在想的是告诉nginx只查看IP地址的前3个块,在这种情况下, 112.112.11.x将能够使用相同的安全下载链接下载相同的文件。 这将有可能使用nginx conf ? 欢迎任何其他select。
这是我的NGINXconfiguration(没有apache,只是php-fpm): user nginx; worker_processes 1; error_log /usr/local/nginx/logs/error.log notice; pid /var/run/nginx.pid; events { worker_connections 384; } http { include mime.types; default_type application/octet-stream; access_log off; server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay off; client_max_body_size 8M; client_body_timeout 30; client_header_timeout 15; keepalive_timeout 15 65; send_timeout 30; gzip on; gzip_static on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 9; gzip_buffers […]
我用三个apache虚拟主机运行Ubuntu 10.10。 我只是按照这个教程在Ubuntu上使用PAssenger和nginx设置Rails 3 。 除了rails / nginx,一切都运行良好。 当我尝试启动它时,我收到以下消息: * Starting Nginx Server… 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] 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 […]
我正在开发一个本地开发虚拟机,并试图用gunicorn和nginx作为静态资源的反向代理来testing我的站点。 该网站用user nginx;加载减去静态资源user nginx; 在nginx.conf中。 尝试单独加载静态资源会显示403 Forbidden错误。 为背景。 静态资源位于/media/sf_work下的共享文件夹中。 所有文件都由root:vboxsf拥有root:vboxsf (VirtualBox默认)。 我在系统上的用户帐户已被添加到vboxsf组,并且我可以完全访问共享文件夹。 为了比较,我尝试将nginx.conf用户更改为我的用户帐户。 在这种情况下,静态文件确实加载,但是然后主页本身给出了一个403 Forbidden错误。 所以,我尝试添加nginx用户到vboxsf组,但是然后一切都给出了一个403 Forbidden错误。 经过进一步调查,似乎如果nginx.conf用户在任何组中,它会导致403禁止。 任何想法可能会发生在这里? UPDATE 因此,当使用我的用户帐户作为nginx用户(静态文件工作的唯一途径)时,返回403 Forbidden的网页问题与目录(目录列表被拒绝)中没有index.html文件有关。 不过,我显然不希望它列出目录; 它应该将这个请求传递给gunicorn代理。 我正在使用以下内容: location / { try_files $uri $uri/ @proxy } location @proxy { proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Scheme $scheme; proxy_connect_timeout 10; proxy_read_timeout 10; proxy_pass http://127.0.0.1:8080; […]