Articles of nginx

Nginx – 在HTTPS上添加一个尾部的斜杠到URL

我正在使用下面的正则expression式来添加一个尾部的斜杠到任何没有栏杆斜线或结束于.. rewrite ^([^.]*[^/])$ $1/ permanent; 这工作正常http ,但是当我使用https它不。 我不知道为什么? 你可以吗?

nginx codeigniter重写:控制器名称与目录冲突

我正在尝试nginx并将我现有的apacheconfiguration移植到nginx。 我设法重新路由codeigniterurl的成功,但我有一个特定的控制器,其名称与站点根目录一致的问题。 我设法使我的codeigniterurl的工作,因为它在Apache中,除了我有一个特定的URL说http://localhost/hello这与网站根目录中的hello目录一致。 Apache对此没有任何问题。 但是nginx路由到这个目录而不是控制器。 我的重新路由结构如下 http://host_name/incoming_url => http://host_name/index.php/incoming_url 所有codeigniter文件都在站点根目录下。 我的nginxconfiguration(相关部分) location / { # First attempt to serve request as file, then # as directory, then fall back to index.html index index.php index.html index.htm; try_files $uri $uri/ /index.php/$request_uri; #apache rewrite rule conversion if (!-e $request_filename){ rewrite ^(.*)/?$ /index.php?/$1 last; } # Uncomment to enable […]

如何用Nginx提供版本号的静态文件?

我刚刚为wordpress完成了Nginx的安装,但所有带有?ver = x的静态文件都被redirect到了nginx的默认页面。 加工 /jquery-ui-1.8.6.custom.min.js redirect到默认的Nginx页面 /jquery-ui-1.8.6.custom.min.js?ver=1 这是我的configuration。 我在这里错过了什么? server { listen 80; root /var/www/domain.com; index index.php index.html index.htm; server_name domain.com; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on […]

“无法分配内存”使用composer从laravel git使用fork安装composer

每当我尝试安装新的laravel项目,我收到以下错误: PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_open(): fork failed – Cannot allocate memory' in phar:///usr/local/bin/composer/vendor/symfony/console/Symfony/Component/Console/Application.php:990 有没有人有任何想法,为什么这个错误可能发生,我在nginx上运行服务器。 如果有任何其他细节可能需要,列出他们作为评论,我会愉快地编辑+更新post,谢谢。

在具有多个虚拟主机的nginx服务器之前清除服务器

我试图寻找一个这样的解决scheme,但不能find任何文档/提示我的具体设置。 我的设置: 后端服务器:ngnix:virtualenv中运行gunicorn / python / django的2个不同网站(2个顶级域名)后端服务器硬件(VPS)2gb ram,8个CPU 数据库服务器:postgresql – pg_bouncer 后端服务器硬件(VPS)1GB RAM,8个CPU 清漆服务器:只运行清漆 Varnishserver硬件(VPS)1GB内存,8个CPU 我试图build立一个清漆服务器来处理罕见的stream量高峰(20 000个唯一请求/秒)当电视节目提到其中一个网站时,就会发生峰值。 我需要做些什么,使清漆服务器caching我的后端服务器上的两个网站/域? 我的/etc/varnish/default.vcl: backend django_backend { .host = "local.backendserver.com"; .port = "8080"; } 我的/usr/local/nginx/site-avaible/domain1.com upstream gunicorn_domain1 { server unix:/home/<USER>/.virtualenvs/<DOMAIN1>/<APP1>/run/gunicorn.sock fail_timeout=0; } server { listen 80; listen 8080; server_name domain1.com; rewrite ^ http://www.domains.com$request_uri? permanent; } server { listen 80 default_server; […]

无法在全新安装中设置nginx + php5-fpm获取404

我只是下载了nginx 1.4,马上就看到“Welcome to nginx!” 消息,那么我已经安装了php5-fpm ,所以我在/usr/share/nginx/html/demo.php上创build了一个php文件,只是用<?php echo "Hello World"; ?> <?php echo "Hello World"; ?>里面。 (我试着在ElementaryOS Ubuntu 12.04的基础上),并遵循本手册: http : //wiki.nginx.org/PHPFcgiExample 然后当我访问http://localhost/demo.php它不起作用,我给了一个404错误。 这是我的/etc/nginx/conf.d/default.conf文件: server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page […]

Nginx的“允许127.0.0.1”允许在所有用户的位置块

问题 我有我的nginxconfiguration下面的块。 这个想法是让服务器访问文件,但没有其他人。 如果其他人访问我应该扔403.如果我注释允许线这是发生了什么事。 但是,如果我把它留在任何人都可以访问它。 我究竟做错了什么? location = /update.php { allow 127.0.0.1; deny all; fastcgi_param SCRIPT_FILENAME /srv/www/mysite/public$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; }

根据上次修改时间使用expires头文件提供服务

在nginx有一种方法来有条件地提供不同的expires头文件取决于文件上次修改时间? 例如,如果foo在上个星期内被修改了,那么我希望它在几个小时内过期,否则我希望它在几天内过期。

NGINX connect()unix:/var/run/php5-fpm/forums.socket失败

我最近用nginx,PHP-FPM重新设置了我的服务器。 我做了我一直做的,但现在的Nginx或PHP-FPM不处理PHP文件。 (我使用php phpinfo();)的最简单forms进行testing。 在我的VHOST的错误日志中,我得到: 2013/12/01 03:59:12 [crit] 1201#0: *5 connect() to unix:/var/run/php5-fpm/forums.socket failed (2: No such file or directory) while connecting to upstream, client: 173.245.53.199, server: forums.DOMAIN.DOM, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm/forums.socket:", host: "forums.DOMAIN.DOM", referrer: "http://forums.DOMAIN.DOM/" 有趣的是,在错误中提到的目录是在那里,但PHP的FPM或Nginx不生成在那里的套接字。 资源: http://paste.ubuntu.com/6502117/

如何设置svn与nginx可以检查通过http协议?

我正在尝试在我的linode服务器(Debian)上设置一个SVN。 https://library.linode.com/linux-tools/version-control/svn我在这里find一篇文章,但它只告诉我如何设置Apache。 我正在使用Nginx,我该如何设置? 我希望build立自己的SVN服务器,并通过http://协议来检查文件,而不是svn+ssh:// 谢谢,