我有一个http块,在其中包含托pipe在同一台服务器上的不同域的虚拟主机。 对于每个虚拟主机我都这样做: listen domain.com:80; 现在,domain2.com工作正常。 但是,当我做www.domain2.com它显示了domain1.com的页面! 如何正确configurationnginx? 如果www是CNAME或Alogging,这有什么关系吗?
你好,ServerFault社区, 我通常是一个StackOverflow lurker / contributor,但是我一直在玩最近的服务器云服务,并且会很感激你的想法。 我构build了web应用程序(通常是小到中等大小的低stream量),目前我有3个在Debian上运行的虚拟机,通过Apache提供networking文件,用MySQL提供数据。 每个VPS运行10到30个站点; 一些自定义应用程序,一些Wordpress和一些静态的HTML网站。 随着我正在玩的新的云服务(目前处于testing阶段,所以它是免费的!)我有能力开始/停止和扩展服务器,我喜欢。 我名单上的第一个实验是用Nginx取代Apache,到目前为止这样做还不错。 然而,我开始怀疑是否有一个优化的服务器通过Nginx服务文件和存储媒体文件,然后是另一个优化的服务器通过MySQL运行和服务数据会有什么好处。 我不知道是否可以做很多事情来优化每个服务器的Web或数据库托pipe,或者是否有任何其他分离服务的好处? 对于这个问题以及我可能错过的其他选项,我将不胜感激。 旁注:使用云服务,我可以select完全自定义服务器,包括内存,磁盘空间和磁盘速度(SATA,SAS,SSD)。
如何实现node.js能够处理250k连接作为彗星服务器(客户端我们使用socket.io)? 将nginx用作代理/负载均衡是否是正确的解决scheme? 或者HA-Proxy会是更好的方法吗? 有没有人有100k +连接的真实世界的经验,可以分享他的设置? 像这样的设置是正确的(每个服务器的四核CPU – >每个服务器启动4个node.js的实例?): nginx (as proxy / load balancing server) / | \ / | \ / | \ / | \ node server #1 node server #2 node server #3 4 instances 4 instances 4 instances
我有一个要求,我需要支持降级我的服务器代码。 我在我的nginxconfiguration文件中有以下行,表明浏览器可以caching页面,但必须通过服务器validation来检查文件是否更改。 add_header Cache-Control "no-cache"; 在我的服务器代码上完成所有升级后,这个设置对我来说工作得非常好。 但是,当把资源降级到旧版本时,当浏览器尝试validation资源更改时,nginx说资源没有改变,所以浏览器显示caching(较新)的资源,而不是降级的(较旧的)资源,资源。 作为一种解决方法,我可以使用以下设置来完全禁用caching,但效率不高,而且我想要caching。 add_header Cache-Control "no-store"; 那么如何让nginx识别降级?
假设我的服务器是www.mydomain.com ,在Nginx 1.0.6上 我试图代理所有的请求到http://www.mydomain.com/fetch到其他主机,目标URL被指定为一个名为“url”的GET参数。 例如,当用户请求任一个时: http://www.mydomain.com/fetch?url=http://another-server.mydomain.com/foo/bar http://www.mydomain.com/fetch?url=http://another-server/foo/bar 它应该被委托给 http://another-server.mydomain.com/foo/bar 我使用下面的nginxconfiguration,只有当url参数包含域名才能正常工作,比如http://another-server.mydomain.com/ … ; 但在http:// another-server / …上出现错误: another-server could not be resolved (3: Host not found) nginx.conf是: http { … # the DNS server resolver 171.10.129.16; server { listen 80; server_name localhost; root /path/to/site/root; location = /fetch { proxy_pass $arg_url; } } 在这里,我想parsing所有在mydomain.com中没有域名的URL作为主机名,在/etc/resolv.conf中,可以指定整个Linux系统的默认search域名,但是不影响nginxparsing: search mydomain.com Nginx可能吗? […]
我试图得到一个非常高性能的web服务器设置处理长轮询,websockets等。我有一个虚拟机运行(Rackspace)与1GB内存/ 4核心。 我已经设置了一个非常简单的gunicorn'hello world'应用程序和(asynchronous)gevent工作者。 在gunicorn之前,我把Nginx和Gunicorn简单的代理放在一起。 使用ab ,Gunicorn吐出7700个请求/秒 ,其中Nginx只有5000个请求/秒 。 预期这种性能下降了吗? 你好,世界: #!/usr/bin/env python def application(environ, start_response): start_response("200 OK", [("Content-type", "text/plain")]) return [ "Hello World!" ] Gunicorn: gunicorn -w8 -k gevent –keep-alive 60 application:application Nginx(剥离): user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; […]
我有以下位置块,作为CMS的复杂路由的一部分: location @mylocation { if (-d $request_filename) { rewrite ^/(.*)$ /$controller/$siteName last; break; } if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") { rewrite ^/(.*)$ /$controller/$siteName/$1 last; } } $controller就像“index.php”, $siteName是一个散列,标识在cms中的特定网站。 它工作正常,nginx重写http://www.mydomain/path?somearg=something到http://www.mydomain/index.php/HASH/path?somearg=something 。 但是当我有一个这样的URL http://www.mydomain/path/?somearg=something nginxredirect(301)到http://www.mydomain/index.php/HASH/path?somearg=something ,和索引.php和HASH都是暴露的。 我尝试了这样的事情: location @mylocation { if (-d $request_filename) { rewrite ^/(.*)$ /$controller/$siteName last; break; } if ($request_filename ~ "") { #not sure what […]
我试图从apache切换到nginx,但是我对bash不是很有经验,所以我遇到了一些麻烦。 我试图在Debian 6上安装最新的稳定版本的nginx,PHP 5.3.10和MySQL 5.5。 默认回购包含过时的产品版本,所以我试图从dotdeb.org回购安装。 问题是dotdeb有一些产品,默认的debian repo也是这样,它提示我安装debain repo的老版本,而不是一个dotdeb。 我试图评论debian repos离开我只是dotdeb的,但现在我不能安装各种产品PHP / MySQL需要的要求(因为dotdeb不包括在他们的回购)。 有没有一种方法来指定我想从某个回购下载东西,并从另一个回购安装要求?
我已经清理了我的nginxconfiguration,用try_filesreplace了所有的if ,但是最后一个是我的。 只有当HTTP方法不是 DELETE我才能像try_files一样行事。 删除用于删除caching的文件。 感谢您的灯光! location / { if ($request_method ~ ^DELETE$) { rewrite ^/(.+)$ /index.php?url=$1 last; } if (-e $request_filename) { break; } if (!-e $request_filename) { rewrite ^/(.+)$ /index.php?url=$1 last; } } 顺便说一句:我越想这个,就越是觉得不安全。
我想转换: http://test.example.com/file.php 要么 http://www.example.com/file.php?subdomain=test 要么 http://test.example.com/file.php?subdomain=test 取决于哪个更简单或更快 这适用于索引页面,但对于子文件夹和文件,它将在redirect循环中获得。 server { listen 80; # Make site accessible from http://localhost/ server_name ~^[^.]+.example.com$; rewrite ^/(.*)/$ /$1 permanent; if ($host ~* ^([^.]+).example.com$) { set $subdomain $1; } rewrite ^(.*)$ $1?subdomain=$subdomain last; location / { root /var/www/example.com; index index.html index.php; } location ~ \.php$ { try_files $uri =404; root /var/www/example.com; […]