Articles of nginx

在nginx内容文件夹中redirectwebapps

我在www.example.com上设置了一个nginx + php + wordpress网站。当我在我的浏览器上访问example.com时,我可以看到我的wordpress博客,并且可以完美地工作,没有问题。 但现在我想继续使用nginx的其他web应用程序而不会丢失博客。 Ningx内容根目录在/srv/www/html WordPress的根目录在/srv/www/wordpress/public_html 我想要例如创build/ srv / www / newsite和放下一些webapp在那里,并能够通过example.com/newsite访问它,这是可能的吗? 我尝试在网站中创build相应的内容,并提供以下内容: server { server_name example.com/newsite www.example.com/newsite; access_log /srv/www/newsite/logs/access.log; error_log /srv/www/newsite/logs/error.log; root /srv/www/newsite; 但它给了我一个wordpress页面没有find。 只是要清楚,我想保持wordpress现在的样子,我希望example.com默认显示我的worpdress。 我只希望example.com/newsite能够提供自己的文件。

如何通过在同一台机器上的squid代理强制从Web服务器/ PHP传出的请求?

我有一个configuration为nginxnetworking服务器的Debian Squeeze VPS。 出于安全原因,我阻止了除Debian更新服务器以外的所有传出连接(这阻止了不好的脚本从家里调用)。 PHP也在单独的用户下运行。 我的问题是以下几点: 各种CMS-S和PHP / Perl / Python应用程序需要访问其他服务器上的Web服务(即,使传出的HTTP连接)。 我已经在同一个 VPS上安装了鱿鱼,并希望将它用作透明的filter/代理,将允许的域列入白名单。 我知道如何通过代理强制所有传出的端口80连接,但这会导致代理自己的请求被redirect到自己(即无限循环)。 我也不能使用iptables的ipt_owner模块,因为VPS公司毫不含糊地告诉我他们不会安装它。 有没有另一个聪明的办法来强制所有其他的HTTP传出请求通过在同一台机器上的鱿鱼代理,同时允许代理自己的请求? 如果有帮助,我也安装了csf。 谢谢!

虚拟DocumentRootconfiguration为WWW和非WWW – 没有redirect

我搜查了很多,但找不到答案 在Apache中设置dynamic虚拟主机时,可以这样做: RewriteEngine On # a ServerName derived from a Host: header may be any case at all RewriteMap lowercase int:tolower ## deal with normal documents first: # allow Alias /icons/ to work – repeat for other aliases RewriteCond %{REQUEST_URI} !^/icons/ # allow CGIs to work RewriteCond %{REQUEST_URI} !^/cgi-bin/ # do the magic RewriteRule ^/(.*)$ […]

如何使用允许SSL的nginx设置CodeIgniter?

我的nginx.conf文件有: server { listen 80; listen 443; server_name www.mysite.com; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; root /var/www/mysite/current; index index.html index.php; location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires max; log_not_found off; } location / { try_files $uri $uri/ /index.php; } location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; include fastcgi.conf; } } 这工作,除了不会在端口443做SSL。任何想法,为什么不呢?

Nginx的404重写问题

我试图抓住斜杠之间的variables,并将它们传递给我的pipe理脚本,在Nginx中有以下重写行: rewrite ^/(.*)/(.*)/(.*)/(.*)/(.*)/(.*)$ /index.php?p1=$1&p2=$2&p3=$3&p4=$4&p5=$5&p6=$6; 如果我请求页面less于6个variables(例如:/ var1 / var2 / var3 / var4 / var5 /)404s。 是否有可能使用less于6个variables? (我将需要在我的Web应用程序的不同部分完整的6个variables) 使用Nginx 1.4.1-1.el6 64bit + PHP-FPM在OpenVZ中运行CentOS 6。 提前致谢。

nginx / fpm和PHP_VALUE不工作

我想改变我的Web服务器的单个网站的一些php.ini值: fastcgi_param PHP_VALUE "auto_prepend_file=/var/www/profile/external/header.php \n auto_append_file=/var/www/profile/external/footer.php"; 但FPM完全忽略了这个值。 我试图在vhostconfiguration之上或者位置〜* .php $ {指令下添加这行,但是没有任何作用 这是我在nginx下的虚拟主机configuration: server { listen 80; index index.php index.html; server_name myvisit; root /var/www/mv/head/myvisit/; access_log /var/log/nginx/myvisit-access.log; error_log /var/log/nginx/myvisit-error.log; fastcgi_param PHP_VALUE "auto_prepend_file=/var/www/profile/external/header.php \n auto_append_file=/var/www/profile/external/footer.php"; # Use gzip compression # gzip_static on; # Uncomment if you compiled Nginx using –with-http_gzip_static_module gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; […]

在nginx上select.jscaching

我有一个.js文件,不能被浏览器caching。 由于这个文件,我在我的nginxconfiguration文件中有这个: location ~* .(js)$ { expires epoch; log_not_found off; access_log off; } 然而,这太可怕了:因为一个文件,所有其他的.js文件不会被浏览器caching。 子域中有可能被caching的.js文件。 所以,我可以这样做: •不允许我的主公用文件夹上的所有.js文件被caching,并让所有在子文件夹上的文件都被caching。 我怎样才能在nginx中进行configuration? 谢谢。

延迟,Nginx和PHP-FPM

我有一个高负载的dynamicPHP Web服务,我最近从Apache2转移到Nginx和PHP-FPM。 我发现自移动以来平均请求延迟从0.5秒增加到了1秒。 我不确定系统的瓶颈在哪里,我一直希望能够减less平均延迟,我知道我的机器不是: 受CPU限制 受内存容量限制 受磁盘IO的限制 受networkingIO限制 Nginx通过一个unix套接字将请求转发到PHP-FPM。 内存带宽可能是瓶颈吗? 反正有监视unix套接字的状态吗? 有一个unix套接字池和它们之间的负载平衡是更好吗? 这是我的nginx.conf文件的一部分: worker_processes 2; # one for each processor worker_rlimit_nofile 65536; … fastcgi_buffers 256 16k; fastcgi_buffer_size 32k; fastcgi_max_temp_file_size 0; proxy_buffer_size 32k; proxy_buffers 4 32k; proxy_busy_buffers_size 32k; 和我的php-fpm.conf listen = /var/run/php5-fpm.sock listen.backlog = 2048 pm = static pm.max_children = 64 有什么突出的东西是奇怪的还是错的?

无法使用nginx运行php脚本

我在我的Lubuntu 13.04 32位上安装了nginx,使用: sudo apt-get install php5-fpm sudo apt-get install mercurial libpcre3-dev libssl-dev hg clone -r stable-1.4 http://hg.nginx.org/nginx nginx cd nginx auto/configure –with-http_ssl_module make sudo make install 之后,我禁用了apache: sudo kill $(pidof apache2) sudo update-rc.d -f apache2 remove 我编辑了nginx.conf,现在是: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; […]

Nginx:将所有stream量redirect到即将到来的页面,除了自己的IP

我有一个名为“即将到来”的文件夹,我希望将所有stream量redirect到网站停机维护时。 目前,这是我做的: —–开始—– 位置 / { 允许123.456.789; 否认一切; page_error 403 coming-soon / index.php; } 位置/即将到来{ 允许全部; } – – – 结束 – – – 问题是,如果有人试图访问一个子文件夹(例如/博客),它不会redirect到即将到来的文件夹。 有人可以帮忙吗? 提前致谢!