Articles of nginx

有了nginx,我怎么做所有www站点到非www站点的质量redirect

就像是 server { listen 80 default; server_name _ ; root /home/drew/sites/$host; rewrite ^www(.*) http://$host$1 permanent; }

nginx虚拟主机不工作,所有的虚拟主机都转到默认主机

我只是在运行Ubuntu 10.10的VPS上做了一个干净安装的nginx + php-fpm,nginx正在服务,PHP运行正常,但是我不能添加虚拟主机。 那么,我可以添加它们,但只有一个有效,其余的就是这个第一个。 这是我的第一个虚拟主机,host1: server { listen 80; server_name host1; access_log /var/log/nginx/host1.log; error_log /var/log/nginx/host1.error.log; location / { root /var/www/vhosts/host1/; index index.html index.htm index.php; } location ~ \.php$ { include /etc/nginx/fastcgi_params; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_param SCRIPT_FILENAME /var/www/vhosts/host1/$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_index index.php; } } 第二个,host2: server { listen 80; server_name host2; access_log /var/log/nginx/host2.log; […]

将nginx限制在一个目录下

我想限制一个nginx服务器到一个目录,例如/在这种情况下。 我会推测这是这样的,但它不起作用。 location ~ !(^/example) { return 403; }

Nginx无法从外部访问?

我有一个服务器设置。 这是从127.0.0.1完美,但如果我尝试从我的“真正的”IP永久加载,然后铬说:“无法连接”。 基本上它不允许外部访问。 我在一台Ubuntu 10.10的路由器后面。 我不知道我是否有防火墙,但是我没有安装任何防火墙。 我认为这是路由器。 这是汤姆逊TCW710。 我不确定是否有正确的端口转发端口80。 这不仅是nginx。 有任何想法吗?

代理多个端口上的同一台服务器?

我忙于configuration一个驻留在一台服务器上的nginx反向代理,它将位于另一台服务器上的apache Web服务器前面,这个服务器将通过mod_wsgi服务于一个Django应用。 在几天前仔细阅读互联网的过程中,我看到一些nginxconfiguration示例,其中有一个服务器在上游指令中设置了多个端口。 所以,而不是这样做(我现在所做的或多或less) upstream webserver { server backend1.com; } 他有: upstream webserver { server backend1.com:8000; server backend1.com:8001; server backend1.com:8002; } 显然,Apacheconfiguration为监听这三个端口。 (我认为在我看到的例子中,我不能再发现它,它是一个运行Rails的杂种后端,无论值多less钱)。 无论如何,我的问题是,这种方法有什么样的优点或缺点? 我知道任何一种方式的作品,我可以很容易地configuration任何选项,但我只是想知道是否有人可以阐明这是一个好/坏/不必要的configuration,为什么。 非常感谢您提供的任何智慧。

nginxredirect域www.domain(ssh)

问候大家! 我有一个奇怪的问题与Nginx。 我想将所有来自domain.com的stream量redirect到www.domain.com。 我也想redirect安全的:https:// domain.com到https:// www.domain.com。 我的configuration是: server { listen 80; listen 443 ssl; server_name domain.com; rewrite ^ $scheme://www.domain.com$request_uri? permanent; } and under here is a server section to handle the www.domain.com domain.com立即被redirect到www.domain.com。 安全的(https:// domain.com)不是。 我收到警告,证书发给www.domain.com等。 任何build议都比欢迎! 谢谢! 供参考:我是新的,所以我不知道如何接受答案和东西,以便人们得到积分。 请原谅:)

最轻的静态网站IP地理定位技术?

我运行一个站点,后面是一个Squid反向代理,它提供了大部分caching的内容(包括html,不仅仅是图像等)。 我需要为位于美国的用户展示不同的内容。 为了做到这一点,我们有什么解决scheme? 我想过使用像edgedirector.com一些地理DNS服务,并将美国用户移动到不同的IP,但我对地理DNS解决scheme严重怀疑。 据我所知,edgedirector只能知道客户使用的ISP的DNS服务器(或OpenDNS,谷歌公共DNS等)的位置,但不知道客户的位置。 我真不明白他们怎么知道客户端的IP,客户端不需要直接查询edgedirector。 我认为另一个解决scheme是使用JavaScript和MaxMind GeoIP Javascript Web服务或Google API客户端位置,但这将是太慢了。 我也想过使用一些反向代理,如Squid,Varnish,Ngninx等,它们直接与Maxmind软件(或其他软件)协同工作,而不需要到后端(比如每个国家的caching副本)。 不知道这是可能的鱿鱼或一些其他反向代理。

在ubuntu 10.04 LTS上部署带有nginx和mongrel集群的Rails应用程序

我将mongrel集群和nginx模块安装到我的虚拟机上。 工作环境是 ruby 1.9.2 rails 3.0.6 rubygems 1.7.2 mongrel_cluster 1.0.5 mongrel 1.2 当我启动杂种群,它会抛出以下错误。 应用程序脱机请build议我一些解决scheme。 我已经尝试了很多使用Google的解决scheme,并没有解决这个问题。 任何forms的帮助表示赞赏。 *starting port 8011 NOTE: Gem::SourceIndex.from_installed_gems is deprecated with no replacement. It will be removed on or after 2011-10-01. Gem::SourceIndex.from_installed_gems called from /usr/local/lib/ruby/gems/1.9.1/gems/gem_plugin-0.2.3/lib/gem_plugin.rb:109 . NOTE: from_installed_gems(arg) is deprecated. From /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/deprecate.rb:62:in `block (2 levels) in deprecate' NOTE: Gem::SourceIndex.from_gems_in is deprecated with […]

504在nginx + apache + mod_wsgi上的网关超时

我使用mod_wsgi运行django应用程序,并使用nginx进行代理。 我的一个观点需要2分钟才能完成。 当我访问它,我得到一个504网关超时。 有没有我可以改变的设置来增加超时所需的时间? 我已经尝试了nginx中的proxy_connect_timeout,proxy_read_timeout和proxy_send_timeout,没有任何运气。 谢谢。

在nginx上设置子域名

我使用Nginx在我的服务器上安装了2个应用程序: Rails应用程序 WordPress的博客 我希望rails应用程序可以通过:staging.mydomain.com访问,并且wordpress博客将可以通过访问:blog.mydomain.com 该网站工作正常,但是当我尝试访问博客我得到“欢迎nginx”屏幕。 这里是我的nginxconfiguration: server { listen 80; server_name staging.mydomain.com; rails_env staging; access_log /srv/www/staging/www/logs/access.log; error_log /srv/www/staging/www/logs/error.log; location / { root /srv/www/staging/www/current/trunk/web/public; passenger_enabled on; } } server { listen 80; server_name blog.mydomain.com; try_files $uri $uri/ /index.php; access_log /srv/www/blog.mydomain.com/logs/access.log; error_log /srv/www/blog.mydomain.com/logs/error.log; location ~ \.php$ { root /srv/www/blog.mydomain.com; include fastcgi_params; fastcgi_pass localhost:53217; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } […]